List of usage examples for java.lang String hashCode
public int hashCode()
From source file:org.callimachusproject.auth.DigestAuthenticationManager.java
private String hash(String... values) { long code = 0; if (values != null) { for (String str : values) { code = code * 31 + str.hashCode(); }// w w w.j a va 2 s.c o m } return Long.toString(code, Character.MAX_RADIX); }
From source file:org.openremote.server.inventory.DiscoveryService.java
protected RouteDefinition createDiscoveryRoute(Adapter adapter, String discoveryEndpointUri) { String routeId = "discovery-" + discoveryEndpointUri.hashCode(); return new RouteDefinition(discoveryEndpointUri).id(routeId).autoStartup(false).process(exchange -> { Object discoveryResult = exchange.getIn().getBody(); if (discoveryResult instanceof List) { List resultList = (List) discoveryResult; if (resultList.size() == 0) return; LOG.debug("Processing discovered device list: " + resultList.size()); List<Device> devices = new ArrayList<>(); // TODO Ugly hack to support v2 and v3 device model Object firstResult = resultList.get(0); if (firstResult instanceof DiscoveredDeviceDTO) { // V2 List<DiscoveredDeviceDTO> discoveredDeviceDTOs = exchange.getIn().getBody(List.class); for (DiscoveredDeviceDTO deviceDTO : discoveredDeviceDTOs) { List<DiscoveredDeviceAttrDTO> attributes = deviceDTO.getDeviceAttrs(); String discoveryCommand = null; for (DiscoveredDeviceAttrDTO attribute : attributes) { if (attribute.getName().equals(ATTR_NAME_DEVICE_DISCOVERY_COMMAND)) { discoveryCommand = attribute.getValue(); break; }/* ww w. ja v a 2 s. com*/ } if (discoveryCommand == null) { LOG.warn("Missing discovery command attribute, skipping discovered: " + deviceDTO); continue; } Device converted = convertV2Device(adapter, deviceDTO, discoveryEndpointUri); if (ATTR_VALUE_DEVICE_DISCOVERY_COMMAND_ADD .equals(discoveryCommand.toLowerCase(Locale.ROOT))) { devices.add(converted); } else if (ATTR_VALUE_DEVICE_DISCOVERY_COMMAND_DELETE .equals(discoveryCommand.toLowerCase(Locale.ROOT))) { deviceService.setDeviceOffline(converted.getId()); } else { LOG.warn("Unsupported discovery command attribute, skipping discovered: " + deviceDTO); } } } else if (firstResult instanceof Device) { // V3 devices = (List<Device>) exchange.getIn().getBody(List.class); } Device[] initializedDevices = deviceLibraryService.initializeDevices(adapter, devices); deviceService.addDevices(initializedDevices); EventService eventService = context.hasService(EventService.class); if (eventService != null) eventService.sendEvent(new InventoryDevicesUpdatedEvent()); } }); }
From source file:com.opengamma.masterdb.security.hibernate.fx.NonDeliverableFXForwardSecurityBean.java
@Override protected void propertySet(String propertyName, Object newValue, boolean quiet) { switch (propertyName.hashCode()) { case 1652755475: // forwardDate setForwardDate((ZonedDateTimeBean) newValue); return;/*from w w w . j a v a2s . co m*/ case -934795532: // region setRegion((ExternalIdBean) newValue); return; case -295641895: // payCurrency setPayCurrency((CurrencyBean) newValue); return; case -1338781920: // payAmount setPayAmount((Double) newValue); return; case -1228590060: // receiveCurrency setReceiveCurrency((CurrencyBean) newValue); return; case 984267035: // receiveAmount setReceiveAmount((Double) newValue); return; case 2073187722: // deliverInReceiveCurrency setDeliverInReceiveCurrency((Boolean) newValue); return; } super.propertySet(propertyName, newValue, quiet); }
From source file:com.opengamma.core.config.impl.ConfigItem.java
@SuppressWarnings("unchecked") @Override/* w ww .j a v a2s.c om*/ protected void propertySet(String propertyName, Object newValue, boolean quiet) { switch (propertyName.hashCode()) { case 111972721: // value setValue((T) newValue); return; case -294460212: // uniqueId setUniqueId((UniqueId) newValue); return; case 3373707: // name setName((String) newValue); return; case 3575610: // type setType((Class<?>) newValue); return; } super.propertySet(propertyName, newValue, quiet); }
From source file:dk.netarkivet.common.lifecycle.PeriodicTaskExecutor.java
/** * Builds an executor for a set of tasks. * @param tasks the task definitions.//www . j a v a 2s . co m */ public PeriodicTaskExecutor(PeriodicTask... tasks) { ArgumentNotValid.checkNotNull(tasks, "tasks"); ArgumentNotValid.checkNotNullOrEmpty(Arrays.asList(tasks), "tasks"); this.tasks = tasks; this.exec = new ScheduledThreadPoolExecutor(tasks.length); alive = true; String id = ""; for (PeriodicTask t : tasks) { ScheduledFuture<?> future = exec.scheduleAtFixedRate(t.task, t.secondsBeforeFirstExec, t.secondsBetweenExec, TimeUnit.SECONDS); t.setFuture(future); id += "_" + t.taskId; } checkerThread = new Thread(id.hashCode() + "-checker") { public void run() { while (alive) { checkExecution(); try { Thread.sleep(TimeUtils.SECOND_IN_MILLIS); } catch (InterruptedException e) { if (log.isTraceEnabled()) { log.trace("checkerThread interrupted."); } } } } }; checkerThread.start(); }
From source file:com.opengamma.masterdb.security.hibernate.option.EquityIndexOptionSecurityBean.java
@Override protected Object propertyGet(String propertyName, boolean quiet) { switch (propertyName.hashCode()) { case -266326457: // optionExerciseType return getOptionExerciseType(); case 1373587791: // optionType return getOptionType(); case -891985998: // strike return getStrike(); case -1289159373: // expiry return getExpiry(); case 575402001: // currency return getCurrency(); case 1989774883: // exchange return getExchange(); case 1257391553: // pointValue return getPointValue(); case -1770633379: // underlying return getUnderlying(); }//from w ww .ja va 2 s .co m return super.propertyGet(propertyName, quiet); }
From source file:com.netflix.spinnaker.halyard.deploy.spinnaker.v1.profile.SpinnakerProfile.java
/** * @param node is the node to find required files in. * @return the list of files required by the node to function. *//* w w w. ja v a2 s . c o m*/ List<String> processRequiredFiles(Node node) { List<String> files = new ArrayList<>(); Consumer<Node> fileFinder = n -> files.addAll(n.localFiles().stream().map(f -> { try { f.setAccessible(true); String fPath = (String) f.get(n); if (fPath == null) { return null; } File fFile = new File(fPath); String fName = fFile.getName(); // Hash the path to uniquely flatten all files into the output directory Path newName = Paths.get(spinnakerOutputDependencyPath, Math.abs(fPath.hashCode()) + "-" + fName); File parent = newName.toFile().getParentFile(); if (!parent.exists()) { parent.mkdirs(); } else if (fFile.getParent().equals(parent.toString())) { // Don't move paths that are already in the right folder return fPath; } Files.copy(Paths.get(fPath), newName, REPLACE_EXISTING); f.set(n, newName.toString()); return newName.toString(); } catch (IllegalAccessException e) { throw new RuntimeException("Failed to get local files for node " + n.getNodeName(), e); } catch (IOException e) { throw new HalException( new ProblemBuilder(FATAL, "Failed to backup user file: " + e.getMessage()).build()); } finally { f.setAccessible(false); } }).filter(Objects::nonNull).collect(Collectors.toList())); node.recursiveConsume(fileFinder); return files; }
From source file:com.xpn.xwiki.objects.BaseObject.java
/** * {@inheritDoc}/*from w w w . jav a2 s.c om*/ * * @see com.xpn.xwiki.objects.BaseCollection#hashCode() */ @Override public int hashCode() { String str = getName() + getClassName(); int nb = getNumber(); if (nb > 0) { str += "_" + nb; } return str.hashCode(); }
From source file:com.opengamma.masterdb.security.hibernate.option.FXDigitalOptionSecurityBean.java
@Override protected Object propertyGet(String propertyName, boolean quiet) { switch (propertyName.hashCode()) { case -984864697: // putAmount return getPutAmount(); case 1066661974: // callAmount return getCallAmount(); case -1289159373: // expiry return getExpiry(); case 516393024: // putCurrency return getPutCurrency(); case 643534991: // callCurrency return getCallCurrency(); case -225763273: // paymentCurrency return getPaymentCurrency(); case -295948169: // settlementDate return getSettlementDate(); case -1180327226: // isLong return getIsLong(); }/*w w w . ja va2s . c o m*/ return super.propertyGet(propertyName, quiet); }
From source file:com.opengamma.masterdb.security.hibernate.option.FXOptionSecurityBean.java
@Override protected Object propertyGet(String propertyName, boolean quiet) { switch (propertyName.hashCode()) { case -984864697: // putAmount return getPutAmount(); case 1066661974: // callAmount return getCallAmount(); case -1289159373: // expiry return getExpiry(); case 516393024: // putCurrency return getPutCurrency(); case 643534991: // callCurrency return getCallCurrency(); case -295948169: // settlementDate return getSettlementDate(); case -1180327226: // isLong return getIsLong(); case -266326457: // optionExerciseType return getOptionExerciseType(); }//from w w w. j av a2 s . co m return super.propertyGet(propertyName, quiet); }