List of usage examples for java.util List equals
boolean equals(Object o);
From source file:com.androidzeitgeist.dashwatch.dashclock.ExtensionManager.java
private void setActiveExtensions(List<ComponentName> extensionNames, boolean saveAndNotify) { Map<ComponentName, ExtensionListing> listings = new HashMap<ComponentName, ExtensionListing>(); for (ExtensionListing listing : getAvailableExtensions()) { listings.put(listing.componentName, listing); }//from w w w . jav a2s .c om List<ComponentName> activeExtensionNames = getActiveExtensionNames(); if (activeExtensionNames.equals(extensionNames)) { Log.d(TAG, "No change to list of active extensions."); return; } // Clear cached data for any no-longer-active extensions. for (ComponentName cn : activeExtensionNames) { if (!extensionNames.contains(cn)) { destroyExtensionData(cn); } } // Set the new list of active extensions, loading cached data if necessary. List<ExtensionWithData> newActiveExtensions = new ArrayList<ExtensionWithData>(); for (ComponentName cn : extensionNames) { if (mExtensionInfoMap.containsKey(cn)) { newActiveExtensions.add(mExtensionInfoMap.get(cn)); } else { ExtensionWithData ewd = new ExtensionWithData(); ewd.listing = listings.get(cn); if (ewd.listing == null) { ewd.listing = new ExtensionListing(); ewd.listing.componentName = cn; } ewd.latestData = deserializeExtensionData(ewd.listing.componentName); newActiveExtensions.add(ewd); } } mExtensionInfoMap.clear(); for (ExtensionWithData ewd : newActiveExtensions) { mExtensionInfoMap.put(ewd.listing.componentName, ewd); } synchronized (mActiveExtensions) { mActiveExtensions.clear(); mActiveExtensions.addAll(newActiveExtensions); } if (saveAndNotify) { Log.d(TAG, "List of active extensions has changed."); saveActiveExtensionList(); notifyOnChangeListeners(null); } }
From source file:com.smartitengineering.event.hub.spi.db.DBHubPersistorITCase.java
public void testGetEvents() { final HubPersistentStorer storer = HubPersistentStorerSPI.getInstance().getStorer(); assertTrue(storer.getEvents("-1", 0).size() == 0); assertTrue(storer.getEvents(" ", 0).size() == 0); assertTrue(storer.getEvents(null, 0).size() == 0); assertTrue(storer.getEvents("1", 0).size() == 0); final String content = "<xml>some xml</xml>"; final String contentType = "application/xml"; Event event1 = APIFactory.getEventBuilder() .eventContent(APIFactory.getContent(contentType, IOUtils.toInputStream(content))).build(); storer.create(event1);//from w w w. jav a 2 s . com Event event2 = APIFactory.getEventBuilder() .eventContent(APIFactory.getContent(contentType, IOUtils.toInputStream(content))).build(); storer.create(event2); Event event3 = APIFactory.getEventBuilder() .eventContent(APIFactory.getContent(contentType, IOUtils.toInputStream(content))).build(); storer.create(event3); Event event4 = APIFactory.getEventBuilder() .eventContent(APIFactory.getContent(contentType, IOUtils.toInputStream(content))).build(); event4 = storer.create(event4); Integer placeholderId = NumberUtils.toInt(event4.getPlaceholderId()) + 1; System.out.println("Selected PlaceholderID: " + placeholderId); Event event5 = APIFactory.getEventBuilder() .eventContent(APIFactory.getContent(contentType, IOUtils.toInputStream(content))).build(); storer.create(event5); Event event6 = APIFactory.getEventBuilder() .eventContent(APIFactory.getContent(contentType, IOUtils.toInputStream(content))).build(); storer.create(event6); Event event7 = APIFactory.getEventBuilder() .eventContent(APIFactory.getContent(contentType, IOUtils.toInputStream(content))).build(); storer.create(event7); final Comparator<Event> comparator = new Comparator<Event>() { public int compare(Event o1, Event o2) { if (o1 == null && o2 == null) { return 0; } else { if (o1 == null && o2 != null) { return 1; } else { if (o1 != null && o2 == null) { return -1; } else { final int compareTo = new Integer(NumberUtils.toInt(o1.getPlaceholderId())) .compareTo(NumberUtils.toInt(o2.getPlaceholderId())); return compareTo * -1; } } } } }; final int count = 3; Collection<Event> events = storer.getEvents(placeholderId.toString(), count); assertNotNull(events); assertTrue(events.size() == count); List<Event> sortTestList = new ArrayList<Event>(events); Collections.sort(sortTestList, comparator); List<Event> origList = new ArrayList<Event>(events); System.out.println(origList + " " + sortTestList); assertTrue(origList.equals(sortTestList)); assertEquals(placeholderId.toString(), origList.get(origList.size() - 1).getPlaceholderId()); events = storer.getEvents(placeholderId.toString(), -1 * count); assertNotNull(events); assertTrue(events.size() == count); sortTestList = new ArrayList<Event>(events); Collections.sort(sortTestList, comparator); origList = new ArrayList<Event>(events); System.out.println(origList + " " + sortTestList); assertTrue(origList.equals(sortTestList)); assertEquals(placeholderId.toString(), origList.get(0).getPlaceholderId()); }
From source file:com.mgmtp.perfload.agent.Transformer.java
@Override public byte[] transform(final ClassLoader loader, final String className, final Class<?> classBeingRedefined, final ProtectionDomain protectionDomain, final byte[] classfileBuffer) throws IllegalClassFormatException { final String classNameWithDots = className.replace('/', '.'); EntryPoints entryPoints = config.getEntryPoints(); final Map<String, MethodInstrumentations> methodsConfig = config.getInstrumentations() .get(classNameWithDots);//from w w w .j a v a 2s . c om final boolean isFilter = entryPoints.hasFilter(classNameWithDots); final boolean isServlet = entryPoints.hasServlet(classNameWithDots); if (methodsConfig == null && !isFilter && !isServlet) { // no instrumentation configured for this class // return null, so no transformation is done return null; } logger.writeln("Transforming class: " + classNameWithDots); // flag for storing if at least one hook is weaved in final MutableBoolean weaveFlag = new MutableBoolean(); ClassReader cr = new ClassReader(classfileBuffer); ClassWriter cw = new ClassWriter(cr, ClassWriter.COMPUTE_MAXS); ClassVisitor cv = new ClassVisitor(Opcodes.ASM4, cw) { @Override public MethodVisitor visitMethod(final int access, final String name, final String desc, final String signature, final String[] exceptions) { MethodVisitor mv = super.visitMethod(access, name, desc, signature, exceptions); if (mv != null) { if (isFilter && "doFilter".equals(name) || isServlet && "service".equals(name) && SERVLET_SERVICE_DESC.equals(desc)) { mv = createServletApiHookVisitor(access, name, desc, mv); } if (methodsConfig != null) { MethodInstrumentations methodInstrumentations = methodsConfig.get(name); if (methodInstrumentations != null) { mv = createMeasuringHookVisitor(access, name, desc, mv, methodInstrumentations); } } } return mv; } private MethodVisitor createMeasuringHookVisitor(final int access, final String methodName, final String desc, final MethodVisitor mv, final MethodInstrumentations methodInstrumentations) { boolean weave = false; if (methodInstrumentations.isEmpty()) { // no params configured, so we just weave the hook into any method with this name weave = true; } else { // weave if params match for (List<String> paramClassNames : methodInstrumentations) { Type[] argumentTypes = Type.getArgumentTypes(desc); List<String> classNames = newArrayListWithCapacity(argumentTypes.length); for (Type argumentType : argumentTypes) { classNames.add(argumentType.getClassName()); } if (classNames.equals(paramClassNames)) { weave = true; break; } } } if (weave) { logger.writeln("Instrumenting method: " + classNameWithDots + "." + methodName); weaveFlag.setValue(true); return new MeasuringHookMethodVisitor(access, classNameWithDots, methodName, desc, mv); } return mv; } private MethodVisitor createServletApiHookVisitor(final int access, final String methodName, final String desc, final MethodVisitor mv) { logger.writeln("Adding servlet api hook: " + classNameWithDots + "." + methodName); weaveFlag.setValue(true); return new ServletApiHookMethodVisitor(access, methodName, desc, mv); } }; // accept the visitor in order to perform weaving cr.accept(cv, ClassReader.EXPAND_FRAMES); if (weaveFlag.isTrue()) { byte[] transformedclassBytes = cw.toByteArray(); dumpTransformedClassFile(className, transformedclassBytes); return transformedclassBytes; } // no transformation return null; }
From source file:com.xiaomi.infra.galaxy.sds.client.SdsTHttpClient.java
private HttpAuthorizationHeader createSignatureHeader(List<String> signatureHeaders, List<String> signatureParts) { assert credential != null; assert signatureHeaders.equals(AuthenticationConstants.SUGGESTED_SIGNATURE_HEADERS); HttpAuthorizationHeader auth = new HttpAuthorizationHeader(); auth.setSignedHeaders(signatureHeaders); auth.setSecretKeyId(credential.getSecretKeyId()); auth.setUserType(credential.getType()); auth.setAlgorithm(MacAlgorithm.HmacSHA1); byte[] signature = SignatureUtil.sign(SignatureUtil.MacAlgorithm.HmacSHA1, credential.getSecretKey(), signatureParts);/* www. j a va2 s. c o m*/ auth.setSignature(BytesUtil.bytesToHex(signature)); return auth; }
From source file:org.rhq.core.gui.model.PagedDataModel.java
/** * @see org.richfaces.model.Modifiable#modify(java.util.List, java.util.List) *//*from w w w .java 2s .co m*/ public void modify(List<FilterField> filterFields, List<SortField2> sortFields) { if (!sortRequested) { List<OrderingField> orderingFields = toOrderingFields(sortFields); fixOrder(orderingFields); this.sortRequested = (!orderingFields.equals(this.currentOrderingFields)); if (this.sortRequested) { log.info("*** Sort requested - order: " + orderingFields + ", previous order: " + this.currentOrderingFields); } this.currentOrderingFields = orderingFields; } }
From source file:android.preference.MultiSelectDragListPreference.java
/** * Attempts to persist a set of Strings to the * {@link android.content.SharedPreferences}. * <p>/* w ww . java2 s . c o m*/ * This will check if this Preference is persistent, get an editor from the * {@link PreferenceManager}, put in the strings, and check if we should * commit (and commit if so). * * @param values The values to persist. * @return True if the Preference is persistent. (This is not whether the * value was persisted, since we may not necessarily commit if there * will be a batch commit later.) * @see #getPersistedString(Set) * * @hide Pending API approval */ protected boolean persistStringSet(List<String> values) { if (shouldPersist()) { // Shouldn't store null if (values.equals(getPersistedStringSet(""))) { // It's already there, so the same as persisting return true; } SharedPreferences.Editor editor = mPreferenceManager.getSharedPreferences().edit(); editor.putString(getKey(), StringUtils.join(values, ",")); editor.commit(); return true; } return false; }
From source file:eu.freme.broker.eservices.Pipelines.java
/** * Updates an existing pipeline template. * @param id The id of the pipeline template to update. * @param ownerName The name of the new owner. * @param visibility The visibility of the template. Can be {@literal PUBLIC} or {@literal PRIVATE}. PUBLIC means visible to anyone, * PRIVATE means only visible to the currently authenticated user. * @param persist {@literal true}: store the template until deleted by someone, {@literal false} to guarantee * it to be stored for one week. * @param pipelineInfo A JSON string containing updated pipeline template info. The fields "label", "description", "serializedRequests" * define the pipeline template. * @return A JSON string containing the updated full pipeline info, i.e. the fields "id", "label", "description", * "persist", "visibility", "owner", "serializedRequests". * @throws ForbiddenException The pipeline template is not visible by the current user. * @throws BadRequestException The contents of the request is not valid. * @throws TemplateNotFoundException The pipeline template does not exist. * @throws InternalServerErrorException Something goes wrong that shouldn't go wrong. *///from w ww. ja v a 2 s .c o m @RequestMapping(value = "pipelining/templates/{id}", method = RequestMethod.PUT, consumes = "application/json", produces = "application/json") public ResponseEntity<String> update(@PathVariable(value = "id") long id, @RequestParam(value = "owner", required = false) String ownerName, @RequestParam(value = "visibility", required = false) String visibility, @RequestParam(value = "persist", required = false) String persist, @RequestBody(required = false) String pipelineInfo) { try { Pipeline pipeline = pipelineDAO.findOneById(id); if (pipelineInfo != null && !pipelineInfo.isEmpty()) { eu.freme.eservices.pipelines.serialization.Pipeline pipelineInfoObj = Serializer .templateFromJson(pipelineInfo); String newLabel = pipelineInfoObj.getLabel(); if (newLabel != null && !newLabel.equals(pipeline.getLabel())) { pipeline.setLabel(newLabel); } String newDescription = pipelineInfoObj.getDescription(); if (newDescription != null && !newDescription.equals(pipeline.getDescription())) { pipeline.setDescription(newDescription); } List<SerializedRequest> oldRequests = Serializer.fromJson(pipeline.getSerializedRequests()); List<SerializedRequest> newRequests = pipelineInfoObj.getSerializedRequests(); if (newRequests != null && !newRequests.equals(oldRequests)) { pipeline.setSerializedRequests(Serializer.toJson(newRequests)); } } if (visibility != null && !visibility.equals(pipeline.getVisibility().name())) { pipeline.setVisibility(OwnedResource.Visibility.getByString(visibility)); } if (persist != null) { boolean toPersist = Boolean.parseBoolean(persist); if (toPersist != pipeline.isPersistent()) { pipeline.setPersist(toPersist); } } if (ownerName != null && !ownerName.equals(pipeline.getOwner().getName())) { User newOwner = userDAO.getRepository().findOneByName(ownerName); if (newOwner == null) { throw new BadRequestException( "Can not change owner of the dataset. User \"" + ownerName + "\" does not exist."); } pipeline.setOwner(newOwner); } pipeline = pipelineDAO.save(pipeline); String response = Serializer.toJson(pipeline); return createOKJSONResponse(response); } catch (org.springframework.security.access.AccessDeniedException | InsufficientAuthenticationException ex) { logger.error(ex.getMessage(), ex); throw new ForbiddenException(ex.getMessage()); } catch (OwnedResourceNotFoundException ex) { logger.error(ex.getMessage(), ex); throw new TemplateNotFoundException("Could not find the pipeline template with id " + id); } catch (JsonSyntaxException jsonException) { logger.error(jsonException.getMessage(), jsonException); String errormsg = jsonException.getCause() != null ? jsonException.getCause().getMessage() : jsonException.getMessage(); throw new BadRequestException("Error detected in the JSON body contents: " + errormsg); } catch (eu.freme.common.exception.BadRequestException e) { logger.error(e.getMessage(), e); throw new BadRequestException(e.getMessage()); } catch (Throwable t) { logger.error(t.getMessage(), t); // throw an Internal Server exception if anything goes really wrong... throw new InternalServerErrorException(t.getMessage()); } }
From source file:org.openehr.designer.diff.ArchetypeDifferentiator.java
private void removeUnspecializedValueSets(Archetype diffChild) { for (Iterator<ValueSetItem> iterator = diffChild.getTerminology().getValueSets().iterator(); iterator .hasNext();) {// w w w . j a v a 2s .c o m ValueSetItem valueSetItem = iterator.next(); List<String> parentMembers = flatParentWrapper.getValueSet(valueSetItem.getId()); if (parentMembers != null && parentMembers.equals(valueSetItem.getMembers())) { iterator.remove(); } } }
From source file:org.teavm.idea.daemon.TeaVMBuildDaemon.java
private ClassLoader buildClassLoader(List<String> classPathEntries, boolean incremental) { System.out.println("Classpath: " + classPathEntries); Function<String, URL> mapper = entry -> { try {/*from w w w. j a v a 2s. c o m*/ return new File(entry).toURI().toURL(); } catch (MalformedURLException e) { throw new RuntimeException(entry); } }; List<String> jarEntries = classPathEntries.stream().filter(entry -> entry.endsWith(".jar")) .collect(Collectors.toList()); ClassLoader jarClassLoader = null; if (incremental) { if (jarEntries.equals(lastJarClassPath) && lastJarClassLoader != null) { jarClassLoader = lastJarClassLoader; System.out.println("Reusing previous class path"); } } else { lastJarClassLoader = null; lastJarClassPath = null; } if (jarClassLoader == null) { URL[] jarUrls = jarEntries.stream().map(mapper).toArray(URL[]::new); jarClassLoader = new URLClassLoader(jarUrls); } if (incremental) { lastJarClassPath = jarEntries; lastJarClassLoader = jarClassLoader; } URL[] urls = classPathEntries.stream().filter(entry -> !entry.endsWith(".jar")).map(mapper) .toArray(URL[]::new); return new URLClassLoader(urls, jarClassLoader); }
From source file:org.kuali.coeus.propdev.impl.basic.ProposalDevelopmentHomeController.java
protected boolean isDocumentLevelRolesDirty(List<ProposalUserRoles> currentRoles, List<ProposalUserRoles> newRoles) { return !currentRoles.equals(newRoles); }