List of usage examples for java.util List contains
boolean contains(Object o);
From source file:eu.annocultor.tools.GeneratorOfXmlSchemaForConvertersDoclet.java
private static void findType(ConstructorDoc constr, Formatter formatter) throws Exception { Map<String, String> paramTags = new HashMap<String, String>(); for (ParamTag params : constr.paramTags()) { paramTags.put(params.parameterName(), params.parameterComment()); }//from ww w. j a v a 2 s .c o m boolean first = true; boolean array = false; for (Parameter p : constr.parameters()) { if (array) { throw new Exception( "Error: something after a dimensioned parameter: " + constr.name() + "." + p.name()); } if (p.type().dimension().length() > 0) { array = true; // throw new Exception("Error: Dimensioned parameter " + constr.name() + "." + p.name()); } if (first) { /* if (!"BatchRule".equals(constr.name())) { if (!Path.class.getName().equals(p.type().qualifiedTypeName()) || !p.name().equals("srcPath")) { throw new Exception("To be published in XML, a rule should have the first parameter (Path srcPath, while found (" + p.type().qualifiedTypeName() + " " + p.name() + " in " + constr.name()); } } */ } boolean foundType = false; if (String.class.getName().equals(p.type().qualifiedTypeName())) { formatter.formatElementStart(p.name(), "ac:String", array); foundType = true; } if (Property.class.getName().equals(p.type().qualifiedTypeName())) { formatter.formatElementStart(p.name(), "ac:Property", array); foundType = true; } if (Resource.class.getName().equals(p.type().qualifiedTypeName())) { formatter.formatElementStart(p.name(), "ac:Resource", array); foundType = true; } if (Graph.class.getName().equals(p.type().qualifiedTypeName())) { if (first && !p.name().startsWith("dstGraph")) { throw new Exception( "First parameter of type Graph is expected to start with dstGraph, while found (" + p.type().qualifiedTypeName() + " " + p.name() + " in " + constr.name()); } formatter.formatElementStart(p.name(), "ac:Graph", array); foundType = true; } if (Path.class.getName().equals(p.type().qualifiedTypeName())) { formatter.formatElementStart(p.name(), "ac:Path", array); foundType = true; } if (Lang.class.getCanonicalName().equals(p.type().qualifiedTypeName())) { formatter.formatElementStart(p.name(), "ac:Lang", array); foundType = true; } if (Namespace.class.getCanonicalName().equals(p.type().qualifiedTypeName())) { formatter.formatElementStart(p.name(), "ac:Namespace", array); foundType = true; } if (VocabularyOfTerms.class.getCanonicalName().equals(p.type().qualifiedTypeName())) { formatter.formatElementStart(p.name(), "ac:VocabularyOfTerms", array); foundType = true; } if (VocabularyOfPlaces.class.getCanonicalName().equals(p.type().qualifiedTypeName())) { formatter.formatElementStart(p.name(), "ac:VocabularyOfPlaces", array); foundType = true; } if (VocabularyOfPeople.class.getCanonicalName().equals(p.type().qualifiedTypeName())) { formatter.formatElementStart(p.name(), "ac:VocabularyOfPeople", array); foundType = true; } if (VocabularyOfTime.class.getCanonicalName().equals(p.type().qualifiedTypeName())) { formatter.formatElementStart(p.name(), "ac:VocabularyOfTime", array); foundType = true; } if (p.name().equals("rule")) { Class ruleClass = Class.forName(p.type().qualifiedTypeName()); List superClasses = ClassUtils.getAllSuperclasses(ruleClass); if (!superClasses.contains(Rule.class)) { throw new Exception( "Error: Parameter 'rule' should be of class Rule o its subclasses, while found " + p.type().qualifiedTypeName()); } formatter.formatElementStart(p.name(), "ac:Rule", array); foundType = true; } if (XConverterFactory.MapObjectToObject.class.getCanonicalName().equals(p.type().qualifiedTypeName())) { formatter.formatElementStart(p.name(), "ac:Map", array); foundType = true; } if (paramTags.containsKey(p.name())) { formatter.formatDocumentation(paramTags.get(p.name())); } formatter.formatElementEnd(p.name()); if (!foundType) { throw new Exception("Error: parameter " + constr.name() + "." + p.name() + " of type " + p.typeName() + " that is not allowed in XML signatures"); } first = false; } }
From source file:com.aw.support.beans.BeanUtils.java
public static Object copyProperties(Object source, Object target, String[] propertyNamesToIgnore, boolean ignoreProxy, boolean ignoreCollections) { List<String> propertyNamesToIgnoreList = propertyNamesToIgnore == null ? Collections.EMPTY_LIST : Arrays.asList(propertyNamesToIgnore); BeanWrapper sourceWrap = new BeanWrapperImpl(source); BeanWrapper targetWrap = new BeanWrapperImpl(target); for (PropertyDescriptor propDescriptor : sourceWrap.getPropertyDescriptors()) { String propName = propDescriptor.getName(); //chequear que no esta en la lista a ignorar if (propertyNamesToIgnoreList.contains(propName)) continue; //chequear que se puede leer if (!sourceWrap.isReadableProperty(propName)) continue; //chequear que se puede escribir if (!targetWrap.isWritableProperty(propName)) continue; Object sourceValue = sourceWrap.getPropertyValue(propName); //chequear que objeto no es un proxy if (ignoreProxy && sourceValue != null && Proxy.isProxyClass(sourceValue.getClass())) continue; //chequear que objeto no una collection if (ignoreCollections && sourceValue instanceof Collection) continue; targetWrap.setPropertyValue(propName, sourceValue); }//w w w . j a va 2 s . c o m return target; }
From source file:de.ailis.wlandsuite.game.Game.java
/** * Checks if the specified byte array represents a Wasteland save game. Save * games are discovered by the block size and by the byte offsets 1-8 which * represents the character order and must contain values between 0 and 7 * while all non-zero numbers can only occur once. * * @param bytes/*from w ww . j a v a 2 s . c o m*/ * The byte array to check * @return If it's a save game or not */ private static boolean isSaveGame(final byte[] bytes) { List<Integer> seen; byte b; seen = new ArrayList<Integer>(7); for (int i = 1; i < 8; i++) { b = bytes[i]; if (b > 7) return false; if (b != 0 && seen.contains(Integer.valueOf(b))) return false; seen.add(Integer.valueOf(b)); } return true; }
From source file:models.GroupMember.java
public static Map<Long, Boolean> checkJoinGroup(List<Long> userIdList, Long groupId) { if (CollectionUtils.isEmpty(userIdList) || null == groupId) { return new HashMap<Long, Boolean>(); }/* w w w .j a v a 2 s . co m*/ String hql = "select userId from GroupMember where userId in (:userIdList) and group.id = :groupId"; List<Long> matchList = JPA.em().createQuery(hql, Long.class).setParameter("userIdList", userIdList) .setParameter("groupId", groupId).getResultList(); Map<Long, Boolean> result = new HashMap<Long, Boolean>(); for (Long userId : userIdList) { result.put(userId, matchList.contains(userId)); } return result; }
From source file:com.cloudbees.plugins.deployer.CloudbeesDeployWarTest.java
public static void assertOnArchive(InputStream inputStream) throws IOException { List<String> fileNames = new ArrayList<String>(); ZipInputStream zipInputStream = null; try {//from w ww . ja v a2 s . co m zipInputStream = new ZipInputStream(inputStream); ZipEntry zipEntry = zipInputStream.getNextEntry(); while (zipEntry != null) { fileNames.add(zipEntry.getName()); zipEntry = zipInputStream.getNextEntry(); } } finally { IOUtils.closeQuietly(zipInputStream); } assertTrue(fileNames.contains("META-INF/maven/org.olamy.puzzle.translate/translate-puzzle-webapp/pom.xml")); assertTrue(fileNames.contains("WEB-INF/lib/javax.inject-1.jar")); }
From source file:de.itsvs.cwtrpc.security.RpcSessionManagementFilter.java
@SuppressWarnings("unchecked") public static boolean appliedSessionAuthenticationStrategy(HttpServletRequest request, SessionAuthenticationStrategy strategy) { List<Class<? extends SessionAuthenticationStrategy>> appliedStrategies; appliedStrategies = (List<Class<? extends SessionAuthenticationStrategy>>) request .getAttribute(APPLIED_SESSION_AUTHENTICATION_STRATEGIES_ATTR_NAME); if (appliedStrategies == null) { return false; }// www . ja va2s . c o m return appliedStrategies.contains(strategy.getClass()); }
From source file:net.rim.ejde.internal.ui.launchers.LaunchUtils.java
/** * Returns the device name associated with the given launch configuration. * * @param configuration//from w ww . jav a 2 s . c om * The launch configuration * @return The device name or empty string if any error occurs */ public static DeviceInfo getDeviceInfo(ILaunchConfiguration configuration) { try { String simDir = configuration.getAttribute(IFledgeLaunchConstants.ATTR_GENERAL_SIM_DIR, StringUtils.EMPTY); String bundleName = configuration.getAttribute(IFledgeLaunchConstants.ATTR_GENERAL_BUNDLE, StringUtils.EMPTY); String deviceName = configuration.getAttribute(IFledgeLaunchConstants.ATTR_GENERAL_DEVICE, StringUtils.EMPTY); String configFile = configuration.getAttribute(IFledgeLaunchConstants.ATTR_GENERAL_CONFIG_FILE, StringUtils.EMPTY); IVMInstall vm = LaunchUtils.getVMFromConfiguration(configuration); List<DeviceInfo> devices = LaunchUtils.getDevicesInfo(vm); DeviceInfo di = new DeviceInfo(bundleName, deviceName, simDir, configFile); if (!devices.contains(di)) { return LaunchUtils.getDefaultDeviceInfo(vm); } return di; } catch (CoreException e) { _logger.error(e); } return null; }
From source file:models.GroupMember.java
/** * ???/*from ww w.ja v a 2 s . c o m*/ * @param userId * @param groupIdList * @return Map<GroupId, isJoined> */ public static Map<Long, Boolean> checkJoinGroup(Long userId, List<Long> groupIdList) { if (CollectionUtils.isEmpty(groupIdList) || null == userId) { return new HashMap<Long, Boolean>(); } String hql = "select group.id from GroupMember where userId = :userId and group.id in (:groupIdList)"; List<Long> matchList = JPA.em().createQuery(hql, Long.class).setParameter("userId", userId) .setParameter("groupIdList", groupIdList).getResultList(); Map<Long, Boolean> result = new HashMap<Long, Boolean>(); for (Long groupId : groupIdList) { result.put(groupId, matchList.contains(groupId)); } return result; }
From source file:Main.java
/** * Method by Adrian: [//from ww w . j av a2 s. c o m * <a href="http://stackoverflow.com/a/15704264/5620200">StackOverflow</a> ] * & Mike: [ <a href= * "http://stackoverflow.com/questions/1542170/arranging-nodes-in-a-jtree"> * StackOverflow</a> ] * * @param node * @return */ @SuppressWarnings("unchecked") public static DefaultMutableTreeNode sort(DefaultMutableTreeNode node) { List<DefaultMutableTreeNode> children = Collections.list(node.children()); List<String> orgCnames = new ArrayList<String>(); List<String> cNames = new ArrayList<String>(); DefaultMutableTreeNode temParent = new DefaultMutableTreeNode(); for (DefaultMutableTreeNode child : children) { DefaultMutableTreeNode ch = (DefaultMutableTreeNode) child; temParent.insert(ch, 0); String uppser = ch.toString().toUpperCase(); // Not dependent on package name, so if duplicates are found // they will later on be confused. Adding this is of // very little consequence and fixes the issue. if (cNames.contains(uppser)) { uppser += "$COPY"; } cNames.add(uppser); orgCnames.add(uppser); if (!child.isLeaf()) { sort(child); } } Collections.sort(cNames); for (String name : cNames) { int indx = orgCnames.indexOf(name); int insertIndex = node.getChildCount(); node.insert(children.get(indx), insertIndex); } // Fixing folder placement for (int i = 0; i < node.getChildCount() - 1; i++) { DefaultMutableTreeNode child = (DefaultMutableTreeNode) node.getChildAt(i); for (int j = i + 1; j <= node.getChildCount() - 1; j++) { DefaultMutableTreeNode prevNode = (DefaultMutableTreeNode) node.getChildAt(j); if (!prevNode.isLeaf() && child.isLeaf()) { node.insert(child, j); node.insert(prevNode, i); } } } return node; }
From source file:com.arcusys.liferay.vaadinplugin.util.ControlPanelPortletUtil.java
public static List<File> getLibs(List<File> exclude) { List<File> libs = new ArrayList<File>(); // Add JARs in portal lib directory File[] jars = new File(getPortalLibLocationPath()).listFiles(WidgetsetUtil.JAR_FILES_ONLY); for (File jar : jars) { if (!exclude.contains(jar)) { libs.add(jar);/* w w w. j a v a 2 s . c o m*/ } } return libs; }