Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8067441
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T12:17:43+00:00 2026-06-05T12:17:43+00:00

I have a connector which has two ports. Two ports have a common root

  • 0

I have a connector which has two ports. Two ports have a common root as Resource. I am trying to find that common root for those two ports.

I need a set of elements for one port(p1) which can be found via getParent method. For the other port (p2) I need to check if any of p2’s element does exist in the set. Although I need this method to return an object of type Resource, I am bit stuck at this point. I am getting the following error.

Unexpected problem while loading: ‘java.lang.ClassCastException:
policy.vddl.model.Resource cannot be cast to java.lang.Comparable’
java.lang.ClassCastException: vddl.model.Resource cannot be cast to
java.lang.Comparable at java.util.TreeMap.compare(Unknown Source) at
java.util.TreeMap.put(Unknown Source) at
java.util.TreeSet.add(Unknown Source) at
vddl.product.Product.findCommonRoot(Product.java:357)

private Element findCommonRoot(Connector connector)
{

    List<Port> portList = getListOfPort(connector);
    Port p1 = portList.get(0);
    Set<Element> portElementSet = new TreeSet<Element>();

    Element pathElement = p1.getParent();
    while (pathElement != null)
    {
        portElementSet.add(pathElement);
        pathElement = pathElement.getParent();
    }

    Port p2 = portList.get(1);
    Element pathElement2 = p2.getParent();

    for(Element e: portElementSet)
    {
        if(portElementSet.contains(pathElement2))
            pathElement2 = e;
    }

    return pathElement2;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T12:17:45+00:00Added an answer on June 5, 2026 at 12:17 pm

    Use HashSet instead TreeSet if don’t need the elements to be sorted. HashSet is not sorted and doesn’t need the elements to be comparable.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a situation in which we have two production databases that synchronize with
I have an application which has two Activities, let's call them A and B.
I have a Rails 2.3.11 app which has two key Models: Activity Transaction Live
I have a boost::asio based server which works fine, except that I'm trying to
I am trying to remove two viewcontrollers (that have been added on top of
I have seen it done where someone has set up two application settings; one
I have an InfoPath form which has two data connections: Connection to a SharePoint
I have a table:'Categories' which has two fields:Category_ID and Category. Data in Category_ID field
I currently have a html login page which has two textfields for e-mail address
I am trying to remove two viewcontrollers (that have been added on top of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.