List of usage examples for java.util Objects equals
public static boolean equals(Object a, Object b)
From source file:com.ben12.openhab.model.util.BeanCopy.java
public static <T> void copy(final List<T> source, final List<T> destination, final Function<T, String> idGetter) { for (int i = 0; i < source.size(); i++) { final T newWidget = source.get(i); boolean found = false; int j = i; while (j < destination.size() && !(found = Objects.equals(idGetter.apply(newWidget), idGetter.apply(destination.get(j))))) { j++;// w w w.ja v a2 s . c o m } if (found) { BeanCopy.copy(newWidget, destination.get(j)); if (i != j) { destination.add(i, destination.remove(j)); } } else { destination.add(i, newWidget); } } if (destination.size() > source.size()) { destination.subList(source.size(), destination.size()).clear(); } }
From source file:Main.java
/** * Check whether the given Iterator contains the given element. * @param iterator the Iterator to check * @param element the element to look for * @return {@code true} if found, {@code false} else */// w w w .j av a2 s . c o m public static boolean contains(Iterator<?> iterator, Object element) { if (iterator != null) { while (iterator.hasNext()) { Object candidate = iterator.next(); if (Objects.equals(candidate, element)) return true; } } return false; }
From source file:com.intel.podm.allocation.strategy.matcher.ProcessorMatcher.java
private static boolean areMatched(List<RequestedProcessor> requestedProcessors, List<Processor> availableProcessors) { ProcessorsAllocationMapper mapper = new ProcessorsAllocationMapper(); Map<RequestedProcessor, Processor> mappedProcessors = mapper.map(requestedProcessors, newArrayList(availableProcessors)); return Objects.equals(mappedProcessors.entrySet().size(), requestedProcessors.size()); }
From source file:de.qaware.cloud.deployer.kubernetes.resource.deployment.DeploymentLabelUtil.java
/** * Adds a label to the specified deployment resource. * * @param resourceConfig The config of the deployment. * @param label The label name. * @param value The label value. * @throws ResourceException If the deployment config doesn't contain the path /spec/template/metadata/labels or if * the specified config doesn't belong to a deployment. *//*ww w .ja v a 2 s.c o m*/ static void addLabel(KubernetesResourceConfig resourceConfig, String label, String value) throws ResourceException { if (Objects.equals(resourceConfig.getResourceVersion(), "extensions/v1beta1") && Objects.equals(resourceConfig.getResourceType(), "Deployment")) { try { ContentType contentType = resourceConfig.getContentType(); JsonNode objectTree = ContentTreeUtil.createObjectTree(contentType, resourceConfig.getContent()); JsonNode specNode = ContentTreeUtil.readNodeValue(objectTree, "spec"); JsonNode templateNode = ContentTreeUtil.readNodeValue(specNode, "template"); JsonNode metadataNode = ContentTreeUtil.readNodeValue(templateNode, "metadata"); JsonNode labelsNode = ContentTreeUtil.readNodeValue(metadataNode, "labels"); ContentTreeUtil.addField(labelsNode, label, value); resourceConfig.setContent(ContentTreeUtil.writeAsString(contentType, objectTree)); } catch (ResourceConfigException e) { throw new ResourceException(KUBERNETES_MESSAGE_BUNDLE.getMessage( "DEPLOYER_KUBERNETES_ERROR_DURING_LABEL_MARKING_INVALID_PATH", resourceConfig.getFilename()), e); } } else { throw new ResourceException(KUBERNETES_MESSAGE_BUNDLE.getMessage( "DEPLOYER_KUBERNETES_ERROR_DURING_LABEL_MARKING_INVALID_CONFIG", resourceConfig.getFilename())); } }
From source file:com.evolveum.midpoint.task.api.TaskManagerUtil.java
private static Integer getNodeLimitation(NodeType node, String group) { if (node.getTaskExecutionLimitations() == null) { return null; }/* w ww.j a v a2 s . com*/ group = MiscUtil.nullIfEmpty(group); for (TaskGroupExecutionLimitationType limit : node.getTaskExecutionLimitations().getGroupLimitation()) { if (Objects.equals(group, MiscUtil.nullIfEmpty(limit.getGroupName()))) { return limit.getLimit(); } } for (TaskGroupExecutionLimitationType limit : node.getTaskExecutionLimitations().getGroupLimitation()) { if (TaskConstants.LIMIT_FOR_OTHER_GROUPS.equals(limit.getGroupName())) { return limit.getLimit(); } } return null; }
From source file:com.abdul.onlinemobi.services.Impl.FindCustomerServiceImpl.java
@Override public Customer getCustomer(String id) { Customer customer = new Customer(); List<Customer> allcustomer = customerRepo.findAll(); for (Customer customers : allcustomer) { if (Objects.equals(customers.getCustomerNumber(), id)) { customer = customers;//ww w. j ava 2 s. c o m } } return customer; }
From source file:models.service.UserInfoCookieService.java
/** * ?COOKIE/*from ww w.j av a2 s . co m*/ * * @param isForce ?COOKIE?? */ public static void createOrUpdateCookie(boolean isForce) { Context ct = Context.current(); if (MobileUtil.isMobileUrlPrefix(ct.request().path())) { return; } User user = User.getFromSession(ct.session()); if (null != user) { Long userId = user.getId(); String username = user.getName(); String token = UserAuthService.getTokenInSession(ct.session()); Long userIdInCookie = cookieValueToLong(Constants.COOKIE_USERINFO_ID); String usernameInCookie = cookieValueToDecodedString(Constants.COOKIE_USERINFO_NAME); String tokenInCookie = cookieValueToDecodedString(Constants.COOKIE_USERINFO_TOKEN); if (isForce || !Objects.equals(userIdInCookie, userId)) { ct.response().setCookie(Constants.COOKIE_USERINFO_ID, String.valueOf(userId)); } if (isForce || !Objects.equals(usernameInCookie, username)) { try { ct.response().setCookie(Constants.COOKIE_USERINFO_NAME, URLEncoder.encode(username, "UTF-8")); } catch (UnsupportedEncodingException e) { LOGGER.error("URL?", e); } } if (isForce || !Objects.equals(tokenInCookie, token)) { try { ct.response().setCookie(Constants.COOKIE_USERINFO_TOKEN, URLEncoder.encode(token, "UTF-8")); } catch (UnsupportedEncodingException e) { LOGGER.error("URL?", e); } } } }
From source file:com.haulmont.cuba.web.jmx.JmxConnectionHelper.java
@Nullable protected static ObjectName getObjectName(final MBeanServerConnection connection, final Class objectClass) throws IOException { Set<ObjectName> names = connection.queryNames(null, null); return IterableUtils.find(names, o -> { MBeanInfo info;//from w w w . j a v a 2s .co m try { info = connection.getMBeanInfo(o); } catch (InstanceNotFoundException | UnmarshalException e) { return false; } catch (Exception e) { throw new JmxControlException(e); } return Objects.equals(objectClass.getName(), info.getClassName()); }); }
From source file:org.kitodo.data.elasticsearch.search.SearchRestClient.java
/** * Return singleton variable of type SearchRestClient. * * @return unique instance of SearchRestClient *//*from w ww . j ava 2 s. com*/ public static SearchRestClient getInstance() { if (Objects.equals(instance, null)) { synchronized (SearchRestClient.class) { if (Objects.equals(instance, null)) { instance = new SearchRestClient(); instance.initiateClient(); } } } return instance; }
From source file:th.co.geniustree.dental.model.Authority.java
@Override public boolean equals(Object obj) { if (obj == null) { return false; }/* w w w . j av a 2 s. com*/ if (getClass() != obj.getClass()) { return false; } final Authority other = (Authority) obj; if (!Objects.equals(this.role, other.role)) { return false; } return true; }