@Override public boolean equals(Object obj) { if (obj == null) { return false; } if (!(obj instanceof RaftPeer)) { return false; } RaftPeer other = (RaftPeer) obj; return StringUtils.equals(ip, other.ip); } }
/** * {@inheritDoc} */ @Override public Object getFirstContextValue(final String label) { for (final Pair<String, Object> pair : contextValues) { if (StringUtils.equals(label, pair.getKey())) { return pair.getValue(); } } return null; }
public boolean equals(Object obj) { if (obj instanceof PersistentState) { PersistentState other = (PersistentState) obj; return StringUtils.equals(this.name, other.name) && Arrays.equals(this.bytes, other.bytes); } return false; }
public boolean isLeader(String ip) { if (STANDALONE_MODE) { return true; } if (leader == null) { Loggers.RAFT.warn("[IS LEADER] no leader is available now!"); return false; } return StringUtils.equals(leader.ip, ip); }
/** * {@inheritDoc} */ @Override public List<Object> getContextValues(final String label) { final List<Object> values = new ArrayList<>(); for (final Pair<String, Object> pair : contextValues) { if (StringUtils.equals(label, pair.getKey())) { values.add(pair.getValue()); } } return values; }
public void doRaftAuth(HttpServletRequest req) throws Exception { String token = req.getParameter("token"); if (StringUtils.equals(UtilsAndCommons.SUPER_TOKEN, token)) { return; } String agent = req.getHeader("Client-Version"); if (StringUtils.startsWith(agent, UtilsAndCommons.NACOS_SERVER_HEADER)) { return; } throw new IllegalAccessException("illegal access,agent= " + agent + ", token=" + token); }
/** * {@inheritDoc} */ @Override public DefaultExceptionContext setContextValue(final String label, final Object value) { for (final Iterator<Pair<String, Object>> iter = contextValues.iterator(); iter.hasNext();) { final Pair<String, Object> p = iter.next(); if (StringUtils.equals(label, p.getKey())) { iter.remove(); } } addContextValue(label, value); return this; }
public void consumeLine(String line) { if (StringUtils.equals(line.trim(), "BUILD FAILED")) { reporter.failing("Command reported [BUILD FAILED]."); } } }
private void validateGroupNameUniqueness(List<PipelineConfigs> parts) { String name = parts.get(0).getGroup(); for (PipelineConfigs part : parts) { String otherName = part.getGroup(); if (!StringUtils.equals(otherName, name)) throw new IllegalArgumentException("Group names must be the same in merge"); } }
public AgentConfig getAgentByUuid(String uuid) { for (AgentConfig agentConfig : this) { if (StringUtils.equals(agentConfig.getUuid(), uuid)) { return agentConfig; } } return NullAgent.createNullAgent(uuid); }
public void addPart(BasicPipelineConfigs pipelineConfigs) { if (!StringUtils.equals(pipelineConfigs.getGroup(), this.getGroup())) throw new IllegalArgumentException("Group names must be the same in merge"); this.parts.add(pipelineConfigs); }
protected String destURL(File rootPath, File file, String src, String dest) { String trimmedPattern = rtrimStandardrizedWildcardTokens(src); if (StringUtils.equals(FilenameUtils.separatorsToUnix(trimmedPattern), FilenameUtils.separatorsToUnix(src))) { return dest; } String trimmedPath = removeStart(subtractPath(rootPath, file), FilenameUtils.separatorsToUnix(trimmedPattern)); if (!StringUtils.startsWith(trimmedPath, "/") && StringUtils.isNotEmpty(trimmedPath)) { trimmedPath = "/" + trimmedPath; } return dest + trimmedPath; }
protected String destinationURL(File rootPath, File file, String src, String dest) { String trimmedPattern = rtrimStandardrizedWildcardTokens(src); if (StringUtils.equals(FilenameUtils.separatorsToUnix(trimmedPattern), FilenameUtils.separatorsToUnix(src))) { return dest; } String trimmedPath = removeStart(subtractPath(rootPath, file), FilenameUtils.separatorsToUnix(trimmedPattern)); if (!StringUtils.startsWith(trimmedPath, "/") && StringUtils.isNotEmpty(trimmedPath)) { trimmedPath = "/" + trimmedPath; } return dest + trimmedPath; }
@Test public void testEqualsOnStrings() { assertTrue(StringUtils.equals(null, null)); assertTrue(StringUtils.equals(FOO, FOO)); assertTrue(StringUtils.equals(FOO, new String(new char[] { 'f', 'o', 'o' }))); assertFalse(StringUtils.equals(FOO, new String(new char[] { 'f', 'O', 'O' }))); assertFalse(StringUtils.equals(FOO, BAR)); assertFalse(StringUtils.equals(FOO, null)); assertFalse(StringUtils.equals(null, FOO)); assertFalse(StringUtils.equals(FOO, FOOBAR)); assertFalse(StringUtils.equals(FOOBAR, FOO)); }
public void visit(ModifiedFile file) { if (StringUtils.equals(file.getFileName(), this.file)) { contains = true; } } }
@Test public void testEquals() { final CharSequence fooCs = new StringBuilder(FOO), barCs = new StringBuilder(BAR), foobarCs = new StringBuilder(FOOBAR); assertTrue(StringUtils.equals(null, null)); assertTrue(StringUtils.equals(fooCs, fooCs)); assertTrue(StringUtils.equals(fooCs, new StringBuilder(FOO))); assertTrue(StringUtils.equals(fooCs, new String(new char[] { 'f', 'o', 'o' }))); assertTrue(StringUtils.equals(fooCs, new CustomCharSequence(FOO))); assertTrue(StringUtils.equals(new CustomCharSequence(FOO), fooCs)); assertFalse(StringUtils.equals(fooCs, new String(new char[] { 'f', 'O', 'O' }))); assertFalse(StringUtils.equals(fooCs, barCs)); assertFalse(StringUtils.equals(fooCs, null)); assertFalse(StringUtils.equals(null, fooCs)); assertFalse(StringUtils.equals(fooCs, foobarCs)); assertFalse(StringUtils.equals(foobarCs, fooCs)); }
private void checkAgentUUID(JobIdentifier jobIdentifier, String agentUuid, String state) { JobInstance job = jobInstanceService.buildByIdWithTransitions(jobIdentifier.getBuildId()); if (!StringUtils.equals(job.getAgentUuid(), agentUuid)) { LOGGER.error("Build Instance [{}] is using agent [{}] but is being updated to [{}] from agent [{}]", jobIdentifier.toString(), job.getAgentUuid(), state, agentUuid); throw new InvalidAgentException("AgentUUID has changed in the middle of a job. AgentUUID:" + agentUuid + ", Build: " + job.toString()); } }
public boolean shouldAssignWork(ElasticAgentMetadata metadata, String environment, ElasticProfile elasticProfile, JobIdentifier identifier) { GoPluginDescriptor pluginDescriptor = pluginManager.getPluginDescriptorFor(metadata.elasticPluginId()); Map<String, String> configuration = elasticProfile.getConfigurationAsMap(true); if (!StringUtils.equals(elasticProfile.getPluginId(), metadata.elasticPluginId())) { return false; } return elasticAgentPluginRegistry.shouldAssignWork(pluginDescriptor, toAgentMetadata(metadata), environment, configuration, identifier); }