List of usage examples for java.util Set add
boolean add(E e);
From source file:br.ufal.cideei.soot.instrument.bitrep.BitConfigRep.java
public static SetBitConfigRep localConfigurations(int highestId, UnmodifiableBidiMap atoms) { Set<IConfigRep> localConfigs = new HashSet<IConfigRep>(); for (int index = 0; index < highestId; index++) { localConfigs.add(new BitConfigRep(index, atoms)); }//w w w.ja va 2 s . com return new SetBitConfigRep(localConfigs, atoms, highestId); }
From source file:com.playonlinux.core.utils.Files.java
private static Set<PosixFilePermission> singleIntToFilePermission(Integer mode, String groupType) { Set<PosixFilePermission> permissions = new HashSet<>(9); if (Arrays.asList(new Integer[] { 1, 3, 5, 7 }).contains(mode)) { permissions.add(PosixFilePermission.valueOf(groupType + "_EXECUTE")); }/*w w w . j a v a 2s . com*/ if (Arrays.asList(new Integer[] { 2, 3, 6, 7 }).contains(mode)) { permissions.add(PosixFilePermission.valueOf(groupType + "_WRITE")); } if (Arrays.asList(new Integer[] { 4, 5, 6, 7 }).contains(mode)) { permissions.add(PosixFilePermission.valueOf(groupType + "_READ")); } return permissions; }
From source file:StringUtil.java
/** * <p>Removes specified chars from a string.</p> * * @param aString the string that will be examined to remove chars * @param unWantedCharArray the char array containing the chars * that should be removed from a string// w w w . j a va 2 s . c o m * @return the string after removing the specified chars */ public static String removeCharsFromString(String aString, char[] unWantedCharArray) { Character character = null; // Store unwanted chars in a hashset Set unWantedCharSet = new HashSet(); for (int i = 0; i < unWantedCharArray.length; i++) { character = new Character(unWantedCharArray[i]); unWantedCharSet.add(character); } // Create result String buffer StringBuffer result = new StringBuffer(aString.length()); // For each character in aString, append it to the result string buffer // if it is not in unWantedCharSet for (int i = 0; i < aString.length(); i++) { character = new Character(aString.charAt(i)); if (!unWantedCharSet.contains(character)) { result.append(aString.charAt(i)); } } // Return result return result.toString(); }
From source file:com.netflix.genie.client.sample.ApplicationServiceSampleClient.java
/** * Helper method to quickly create an application for use in samples. * * @param id The id to use or null/empty if want one created. * @return A sample application with id MR2 * @throws GenieException For any issue//from ww w . ja v a 2s. com */ public static Application getSampleApplication(final String id) throws GenieException { final Application app = new Application(APP_NAME, "tgianos", APP_VERSION, ApplicationStatus.ACTIVE); if (StringUtils.isNotBlank(id)) { app.setId(id); } app.setVersion("2.4.0"); final Set<String> configs = new HashSet<>(); configs.add("s3://mybucket/mapred-site.xml"); app.setConfigs(configs); final Set<String> jars = new HashSet<>(); jars.add("s3://mybucket/foo.jar"); app.setJars(jars); final Set<String> tags = new HashSet<>(); tags.add("tag0"); app.setTags(tags); return app; }
From source file:de.xwic.appkit.core.model.EntityModelFactory.java
/** * Creates a new entity model based upon the specified entity. * @param entity/*from ww w .j a v a 2s. c o m*/ * @return * @throws EntityModelException */ @SuppressWarnings("unchecked") public static IEntityModel createModel(IEntity entity) { // create model and InvocationHandler Set<Class<?>> interfacesSet = new HashSet<Class<?>>(); Class<? extends IEntity> clazz = entity.getClass(); interfacesSet.add(IEntityModel.class); // recursivly add all interfaces Class<?> c = clazz; while (c != null) { Class<?>[] orgInterfaces = c.getInterfaces(); for (int i = 0; i < orgInterfaces.length; i++) { interfacesSet.add(orgInterfaces[i]); } c = c.getSuperclass(); } Class[] interfaces = new Class[interfacesSet.size()]; int idx = 0; for (Iterator<Class<?>> it = interfacesSet.iterator(); it.hasNext();) { interfaces[idx++] = it.next(); } EntityModelInvocationHandler ih = new EntityModelInvocationHandler(entity); return (IEntityModel) Proxy.newProxyInstance(classLoader, interfaces, ih); }
From source file:Main.java
public static Set<Class<?>> getAllImplementedInterfaceNames(Class<?> klass) { Set<Class<?>> interfaces = new HashSet<Class<?>>(); while (klass != null) { Class<?>[] localInterfaces = klass.getInterfaces(); for (Class<?> intf : localInterfaces) { interfaces.add(intf); exploreSuperInterfaces(intf, interfaces); }//ww w . ja v a2 s . co m klass = klass.getSuperclass(); } return interfaces; }
From source file:Main.java
/** * Returns a set of the direct ancestors of each element in elements. * If one element does not have an ancestor, the whole set will be empty. */// w w w .j a va2s . c o m public static Set<Element> getDirectAncestors(Set<Element> elements) { Set<Element> directAncestors = new HashSet<Element>(); for (Element element : elements) { if (element.getParentNode() != null && element.getParentNode() instanceof Element) { directAncestors.add((Element) element.getParentNode()); } else { return new HashSet<Element>(); } } return directAncestors; }
From source file:org.web4thejob.util.L10nUtil.java
public static List<L10nString> getLocalizableResources(final Class<?> localizable) { final List<L10nString> strings = new ArrayList<L10nString>(); final Set<Class> classes = new HashSet<Class>(); classes.add(localizable); classes.addAll(ClassUtils.getAllInterfacesForClassAsSet(localizable)); for (Class<?> clazz : classes) { ReflectionUtils.doWithFields(clazz, new ReflectionUtils.FieldCallback() { @Override//w w w .jav a 2 s . c o m public void doWith(Field field) throws IllegalArgumentException, IllegalAccessException { strings.add((L10nString) field.get(null)); } }, new ReflectionUtils.FieldFilter() { @Override public boolean matches(Field field) { return ReflectionUtils.isPublicStaticFinal(field) && L10nString.class.equals(field.getType()); } }); } //get localizable resources from extension modules for (Module module : ContextUtil.getModules()) { if (module instanceof LocalizableModule) { strings.addAll(((LocalizableModule) module).getLocalizableStrings(classes)); } } // add commands,settings and global strings here... if (DesktopLayoutPanel.class.isAssignableFrom(localizable)) { for (CommandEnum commandEnum : CommandEnum.values()) { L10nString l10nString = new L10nString(CommandEnum.class, commandEnum.name(), L10nUtil.getMessage(commandEnum.getClass(), commandEnum.name(), commandEnum.name())); strings.add(l10nString); } for (SettingEnum settingEnum : SettingEnum.values()) { L10nString l10nString = new L10nString(SettingEnum.class, settingEnum.name(), L10nUtil.getMessage(settingEnum.getClass(), settingEnum.name(), settingEnum.name())); strings.add(l10nString); } for (Condition condition : Condition.getConditions()) { L10nString l10nString = new L10nString(Condition.class, condition.getKey(), condition.getKey()); strings.add(l10nString); } } return strings; }
From source file:ddf.catalog.source.solr.provider.SolrProviderTestUtil.java
public static Set<AttributeDescriptor> numericalDescriptors(String doubleField, String floatField, String intField, String longField, String shortField) { Set<AttributeDescriptor> descriptors = new HashSet<>(); descriptors.add(new AttributeDescriptorImpl(Metacard.ID, true, true, true, false, BasicTypes.STRING_TYPE)); descriptors.add(new AttributeDescriptorImpl(doubleField, true, true, true, false, BasicTypes.DOUBLE_TYPE)); descriptors.add(new AttributeDescriptorImpl(floatField, true, true, true, false, BasicTypes.FLOAT_TYPE)); descriptors.add(new AttributeDescriptorImpl(intField, true, true, true, false, BasicTypes.INTEGER_TYPE)); descriptors.add(new AttributeDescriptorImpl(longField, true, true, true, false, BasicTypes.LONG_TYPE)); descriptors.add(new AttributeDescriptorImpl(shortField, true, true, true, false, BasicTypes.SHORT_TYPE)); return descriptors; }
From source file:cz.muni.fi.editor.database.test.helpers.AbstractDAOTest.java
protected static void checkMethods(Class testClass, Class testingInterface) { Set<String> testMethods = new HashSet<>(); for (Method m : testClass.getDeclaredMethods()) { if (m.isAnnotationPresent(Test.class)) { testMethods.add(m.getName()); }/*from ww w .ja va 2 s . co m*/ } List<String> targetMethods = new ArrayList<>( Arrays.asList("create", "update", "getById", "delete", "getAll", "getClassType")); targetMethods.addAll(new ArrayList<>(Arrays.asList(testingInterface.getDeclaredMethods())).stream() .map(m -> m.getName()).collect(Collectors.toList())); testMethods.forEach(targetMethods::remove); Assert.assertEquals("Following method(s) are missing in DAO test :" + targetMethods.toString(), 0, targetMethods.size()); }