List of usage examples for java.util Set equals
boolean equals(Object o);
From source file:com.tesora.dve.tools.aitemplatebuilder.AiTemplateBuilder.java
public static Set<ForeignRelationship> getNonCollocatedFks(final TableStats table, final Set<? extends TemplateRangeItem> availableRanges) { final Set<ForeignRelationship> nonCollocatedRelationships = new LinkedHashSet<ForeignRelationship>(); for (final ForeignRelationship relationship : table.getForwardRelationships()) { final TableStats lhs = relationship.getLHS(); final TableStats rhs = relationship.getRHS(); if (rhs.getTableDistributionModel().isBroadcast()) { continue; // Range -> Broadcast and Broadcast -> Broadcast are always collocated. } else if (lhs.getTableDistributionModel().isBroadcast()) { nonCollocatedRelationships.add(relationship); continue; // Broadcast -> Range cannot be collocated. }//w w w . j a v a 2 s. c o m final TemplateRangeItem leftRange = findRangeForTable(availableRanges, lhs); final TemplateRangeItem rightRange = findRangeForTable(availableRanges, rhs); if ((leftRange == null) || (rightRange == null)) { nonCollocatedRelationships.add(relationship); // Tables not in a single range. continue; } final Set<TableColumn> leftColumns = leftRange.getRangeColumnsFor(lhs); final Set<TableColumn> rightColumns = rightRange.getRangeColumnsFor(rhs); if (!leftRange.equals(rightRange) || !leftColumns.equals(relationship.getLeftColumns()) || !rightColumns.equals(relationship.getRightColumns())) { nonCollocatedRelationships.add(relationship); } } return nonCollocatedRelationships; }
From source file:net.solarnetwork.node.power.impl.sma.sunnynet.SMASunnyNetPowerDatumDataSource.java
private void setupChannelNamesToMonitor() { Set<String> s = new LinkedHashSet<String>(3); s.add(getPvVoltsChannelName());//from www . ja v a 2 s . c o m s.add(getPvAmpsChannelName()); s.add(getkWhChannelName()); if (!s.equals(this.getChannelNamesToMonitor())) { setChannelNamesToMonitor(s); this.channelMap = null; } }
From source file:specminers.smartic.MergingBlock.java
public boolean checkUnifiable(State<String> nx, State<String> ny, boolean isTopDown, Automaton<String> x, Automaton<String> y) { Set<List<Step<String>>> txS = new HashSet<>(); Set<List<Step<String>>> tyS = new HashSet<>(); if (!isTopDown) { txS = getSuffixes(x, nx);/* ww w. j a v a 2 s . c o m*/ tyS = getSuffixes(y, ny); } else { txS = getPrefixes(x, nx); tyS = getPrefixes(y, ny); } boolean isUnifiable = false; Set<List<TransitionString>> xTransitionList = txS.stream().map(lx -> { List<TransitionString> trx = lx.stream().map(sx -> new TransitionString(sx, x)) .collect(Collectors.toList()); return trx; }).collect(Collectors.toSet()); Set<List<TransitionString>> yTransitionList = tyS.stream().map(ly -> { List<TransitionString> trx = ly.stream().map(sy -> new TransitionString(sy, y)) .collect(Collectors.toList()); return trx; }).collect(Collectors.toSet()); isUnifiable = yTransitionList.equals(xTransitionList); return isUnifiable; }
From source file:fr.mby.portal.coreimpl.acl.MemoryAclDaoTest.java
@Test public void testRevokeRoles() throws Exception { final Principal testPrincipal = new PortalUserPrincipal("test"); this.memoryAclDao.registerPrincipal(testPrincipal); final IRole role1 = this.basicRoleFactory.initializeRole(MemoryAclDaoTest.TEST_ROLE_NAME_1, null, null); this.memoryAclDao.createRole(role1); final IRole role2 = this.basicRoleFactory.initializeRole(MemoryAclDaoTest.TEST_ROLE_NAME_2, null, null); this.memoryAclDao.createRole(role2); // Grant role 1 & 2 this.memoryAclDao.grantRoles(testPrincipal, AclHelper.buileRoleSet(role1, role2)); final Set<IRole> roles = this.memoryAclDao.findPrincipalRoles(testPrincipal); Assert.assertNotNull("Roles set should not be null after registration !", roles); Assert.assertTrue("Roles set size should be 1 after granting the role !", roles.size() == 2); // Revoke role 1 final Set<IRole> refreshedRoles = this.memoryAclDao.revokeRoles(testPrincipal, AclHelper.buileRoleSet(role1)); final Set<IRole> rolesAfterRevoke = this.memoryAclDao.findPrincipalRoles(testPrincipal); Assert.assertNotNull("Roles set should not be null after registration !", rolesAfterRevoke); Assert.assertTrue("Roles set size should be 1 after granting the role !", rolesAfterRevoke.size() == 1); Assert.assertEquals("Roles should be role 2 after revoking role 1 !", role2, rolesAfterRevoke.iterator().next()); Assert.assertTrue("Roles sets found and return by grant method shoud be equals !", rolesAfterRevoke.equals(refreshedRoles)); }
From source file:de.hybris.platform.test.CaseInsensitiveStringMapTest.java
@Test public void testValues() { final Set<String> values = new HashSet<String>(// Arrays.asList("AAA", "BBB", "CCC", "ddd", "x", "y", "\u00df", "\u00dc", "")); final Set<String> wrongValues = new HashSet<String>(// Arrays.asList("aaa", "bbb", "ccc", "ddd", "x", "y", "\u00df", "\u00dc", "")); final Map<String, String> testMap = new CaseInsensitiveStringMap<String>(); for (final String v : values) { testMap.put(v, v);/*from w w w . j a v a 2s.c o m*/ } Assert.assertTrue(testMap.containsValue("AAA")); Assert.assertFalse(testMap.containsValue("aaa")); Assert.assertEquals(values, new HashSet<String>(testMap.values())); Assert.assertFalse(wrongValues.equals(new HashSet<String>(testMap.values()))); }
From source file:com.wbrenna.gtfsoffline.MainActivity.java
@Override protected void onResume() { super.onResume(); //we want to refresh the databases list Set<String> emptyString = new HashSet<String>(); emptyString.clear();//from ww w . j a v a 2 s. c o m Set<String> initial_preferences = mPrefs.getStringSet(getString(R.string.pref_dbs), emptyString); //in case we're on a low-ram system and things aren't cached try { if (!initial_preferences.equals(mDBListPrefsOld)) { mDBListPrefsOld = initial_preferences; //this is the list of currently checked databases mDBActive = null; //just to nullify the previous one. if (initial_preferences.size() != 0) { String[] tmpDBActive = initial_preferences.toArray(new String[initial_preferences.size()]); dbHelper.gatherFiles(); mDBList = dbHelper.GetListofDB(); List<String> workingDBList = new ArrayList<String>(); for (int i = 0; i < tmpDBActive.length; i++) { if (mDBList.contains(tmpDBActive[i])) { workingDBList.add(tmpDBActive[i]); } } if (workingDBList.size() == 0) { mDBActive = null; } else { mDBActive = workingDBList.toArray(new String[workingDBList.size()]); } } mSectionsPagerAdapter.notifyDataSetChanged(); //totally kill the viewPager and all, and recreate! //mSectionsPagerAdapter = null; //getFragmentManager().beginTransaction().replace(containerViewId, fragment); //and create the appropriate tabs final ActionBar actionBar = getActionBar(); /**mSectionsPagerAdapter = new SectionsPagerAdapter( getSupportFragmentManager()); // Set up the ViewPager with the sections adapter. mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mSectionsPagerAdapter); mViewPager .setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { actionBar.setSelectedNavigationItem(position); } });**/ if (actionBar != null) { actionBar.removeAllTabs(); } for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) { actionBar.addTab( actionBar.newTab().setText(mSectionsPagerAdapter.getPageTitle(i)).setTabListener(this)); //update the fragment contents /**if (i > 0 ) { Fragment newFragment = new DBListFragment(); Bundle args = new Bundle(); args.putString(DBListFragment.DATABASE, mDBActive[i-1]); newFragment.setArguments(args); getFragmentManager().beginTransaction().replace(i, newFragment); }**/ if (i > 0) { DBListFragment aFragment = (DBListFragment) getSupportFragmentManager() .findFragmentByTag("android:switcher:" + R.id.pager + ":" + Integer.toString(i)); if (aFragment != null) { getSupportFragmentManager().beginTransaction().remove(aFragment).commit(); mSectionsPagerAdapter.notifyDataSetChanged(); //if (aFragment.getView() != null) { //aFragment.updateDisplay(); //} } } else if (i == 0) { FavSectionFragment aFavFragment = (FavSectionFragment) getSupportFragmentManager() .findFragmentByTag("android:switcher:" + R.id.pager + ":" + Integer.toString(i)); if (aFavFragment != null) { //getSupportFragmentManager().beginTransaction().remove(aFavFragment).commit(); //mSectionsPagerAdapter.notifyDataSetChanged(); //if (aFavFragment.getView() != null) { //aFavFragment.updateDisplay(); //} aFavFragment.updatePositions(); } } } } } finally { //restart location manager //mLocationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE); mLocationHelper.refresh(locationListener); } }
From source file:com.evolveum.midpoint.model.impl.lens.projector.PolicyRuleProcessor.java
@Nullable private PropertyDelta<String> createSituationDelta(ItemPath path, Set<String> currentSituations, Set<String> newSituations) throws SchemaException { if (newSituations.equals(currentSituations)) { return null; }// ww w . j a va 2s . c o m @SuppressWarnings({ "unchecked", "raw" }) PropertyDelta<String> situationsDelta = (PropertyDelta<String>) DeltaBuilder .deltaFor(FocusType.class, prismContext).item(path) .add(CollectionUtils.subtract(newSituations, currentSituations).toArray()) .delete(CollectionUtils.subtract(currentSituations, newSituations).toArray()).asItemDelta(); situationsDelta.setEstimatedOldValues(PrismPropertyValue.wrap(currentSituations)); return situationsDelta; }
From source file:org.lockss.account.UserAccount.java
/** Set the user's roles */ public void setRoles(Set roleSet) { if (log.isDebug2()) log.debug2(userName + ".setRoles(" + roleSet + ")"); if (!roleSet.equals(getRoleSet())) { addAuditableEvent("Changed roles from: " + getRoleSet() + " to: " + roleSet); setChanged(true);/*from w ww . j a va 2 s .com*/ this.roles = StringUtil.separatedString(roleSet, ","); this.roleSet = roleSet; } }
From source file:net.solarnetwork.central.dras.biz.dao.DaoBizSupport.java
/** * Helper method for maintaining the membership relationship in a group. * /*from w ww.j a va2 s. c om*/ * @param membership the command * @param access API for updating the group membership * @return the EffectiveCollection representing the new membership status */ protected <T extends Entity<Long>, E extends Member> EffectiveCollection<T, E> maintainGroupMembership( MembershipCommand membership, MembershipMaintenance<T, E> access) { Effective eff; boolean newEffective = false; if (membership.getEffectiveId() != null) { eff = effectiveDao.get(membership.getEffectiveId()); } else { eff = createEffective(null); newEffective = true; } Set<E> members = access.getMembers(membership.getParentId(), eff); Set<E> newMembers = new HashSet<E>(members.size() + membership.getGroup().size()); Set<E> actionMembers = new LinkedHashSet<E>(membership.getGroup().size()); for (Long memberId : membership.getGroup()) { actionMembers.add(access.createMember(memberId)); } switch (membership.getMode()) { case Append: newMembers.addAll(members); newMembers.addAll(actionMembers); break; case Delete: newMembers.addAll(members); newMembers.removeAll(actionMembers); break; case Replace: newMembers.addAll(actionMembers); } if (newMembers.equals(members)) { // no change, clean up and return if (newEffective) { effectiveDao.delete(eff); eff = null; // TODO: or get the actual Effective from userGroupDao? } } else { Set<Long> ids = new HashSet<Long>(newMembers.size()); for (Member m : newMembers) { ids.add(m.getId()); } access.assignMembers(membership.getParentId(), ids, eff); } T userGroup = access.getDao().get(membership.getParentId()); EffectiveCollection<T, E> result = new EffectiveCollection<T, E>(eff, userGroup, newMembers); return result; }
From source file:com.evolveum.midpoint.model.impl.lens.projector.PolicyRuleProcessor.java
private PropertyDelta<EvaluatedPolicyRuleTriggerType> createTriggerDelta(ItemPath path, Set<EvaluatedPolicyRuleTriggerType> currentTriggers, Set<EvaluatedPolicyRuleTriggerType> newTriggers) throws SchemaException { if (newTriggers.equals(currentTriggers)) { return null; }/*from w w w .j a v a2s.c om*/ @SuppressWarnings({ "unchecked", "raw" }) PropertyDelta<EvaluatedPolicyRuleTriggerType> triggersDelta = (PropertyDelta<EvaluatedPolicyRuleTriggerType>) DeltaBuilder .deltaFor(FocusType.class, prismContext).item(path).replace(newTriggers.toArray()) // TODO or add + delete? .asItemDelta(); triggersDelta.setEstimatedOldValues(PrismPropertyValue.wrap(currentTriggers)); return triggersDelta; }