/** * Creates an hamcrest matcher that is evalued to true if the value of the given argument satisfies * the condition defined by the passed matcher. * @param argument The argument defined using the {@link ch.lambdaj.Lambda#on(Class)} method that has to be matched * @param matcher The matcher against which the value of the given argument has to be compared * @return The hamcrest matcher that is evalued to true if the value of the passed argument matches the given matcher */ @Factory public static <T, A> HasArgumentWithValue<T, A> havingValue(A argument, Matcher<?> matcher) { return new HasArgumentWithValue<T, A>(actualArgument(argument), matcher); }
/** * Creates an hamcrest matcher that is evalued to true accordingly to the value of the passed argument * @param argument The boolean argument defined using the {@link Lambda#on(Class)} method that has to be matched * @return The hamcrest matcher that is evalued to true accordingly to the value of the passed argument */ public static <T> HasArgumentWithValue<T, Boolean> having(Boolean argument) { return havingValue(argument); }
public ManagedMongoDbLifecycleManager getStartedServer(int port) { return selectFirst( this.servers, having(on(ManagedMongoDbLifecycleManager.class).getPort(), is(port)).and(having(on(ManagedMongoDbLifecycleManager.class).isReady(), is(true)))); }
/** * Get emoji by unicode, short code, decimal html entity or hexadecimal html * entity * * @param code unicode, short code, decimal html entity or hexadecimal html * @return Emoji */ public static Emoji getEmoji(String code) { Matcher m = shortCodePattern.matcher(code); // test for shortcode with colons if (m.find()) { code = m.group(1); } Emoji emoji = selectFirst( EmojiManager.data(), having(on(Emoji.class).getEmoji(), Matchers.equalTo(code)).or(having(on(Emoji.class).getEmoji(), Matchers.equalTo(code))) .or(having(on(Emoji.class).getHexHtml(), Matchers.equalToIgnoringCase(code))) .or(having(on(Emoji.class).getDecimalHtml(), Matchers.equalToIgnoringCase(code))) .or(having(on(Emoji.class).getDecimalSurrogateHtml(), Matchers.equalToIgnoringCase(code))) .or(having(on(Emoji.class).getHexHtmlShort(), Matchers.equalToIgnoringCase(code))) .or(having(on(Emoji.class).getDecimalHtmlShort(), Matchers.equalToIgnoringCase(code))) .or(having(on(Emoji.class).getAliases(), Matchers.hasItem(code))) .or(having(on(Emoji.class).getEmoticons(), Matchers.hasItem(code)))); return emoji; }
private SelectiveMatcher findSelectiveMatcherByConnectionIdentifier( SelectiveMatcher[] selectiveMatchers) { return selectFirst( selectiveMatchers, having(on(SelectiveMatcher.class).identifier(), equalTo(identifier)).and( having(on(SelectiveMatcher.class).location(), notNullValue()))); }
/** * Get emoji by unicode, short code, decimal html entity or hexadecimal html * entity * * @param code unicode, short code, decimal html entity or hexadecimal html * @return Emoji */ public static Emoji getEmoji(String code) { Matcher m = shortCodePattern.matcher(code); // test for shortcode with colons if (m.find()) { code = m.group(1); } Emoji emoji = selectFirst( EmojiManager.data(), having(on(Emoji.class).getEmoji(), Matchers.equalTo(code)).or(having(on(Emoji.class).getEmoji(), Matchers.equalTo(code))) .or(having(on(Emoji.class).getHexHtml(), Matchers.equalToIgnoringCase(code))) .or(having(on(Emoji.class).getDecimalHtml(), Matchers.equalToIgnoringCase(code))) .or(having(on(Emoji.class).getDecimalSurrogateHtml(), Matchers.equalToIgnoringCase(code))) .or(having(on(Emoji.class).getHexHtmlShort(), Matchers.equalToIgnoringCase(code))) .or(having(on(Emoji.class).getDecimalHtmlShort(), Matchers.equalToIgnoringCase(code))) .or(having(on(Emoji.class).getAliases(), Matchers.hasItem(code))) .or(having(on(Emoji.class).getEmoticons(), Matchers.hasItem(code)))); return emoji; }
public ManagedMongoDbLifecycleManager getStoppedServer(int port) { return selectFirst( this.servers, having(on(ManagedMongoDbLifecycleManager.class).getPort(), is(port)).and(having(on(ManagedMongoDbLifecycleManager.class).isReady(), is(false)))); }
/** * Creates an hamcrest matcher that is evalued to true if the value of the given argument satisfies * the condition defined by the passed matcher. * @param argument The argument defined using the {@link Lambda#on(Class)} method that has to be matched * @param matcher The matcher against which the value of the given argument has to be compared * @return The hamcrest matcher that is evalued to true if the value of the passed argument matches the given matcher */ public static <T, A> HasArgumentWithValue<T, A> having(A argument, Matcher<?> matcher) { return havingValue(argument, matcher); }
public ManagedMongoDbLifecycleManager getStartedServer(int port) { return selectFirst( this.servers, having(on(ManagedMongoDbLifecycleManager.class).getPort(), is(port)).and(having(on(ManagedMongoDbLifecycleManager.class).isReady(), is(true)))); }
/** * Creates an hamcrest matcher that is evalued to true accordingly to the value of the passed argument * @param argument The boolean argument defined using the {@link ch.lambdaj.Lambda#on(Class)} method that has to be matched * @return The hamcrest matcher that is evalued to true accordingly to the value of the passed argument */ @Factory public static <T> HasArgumentWithValue<T, Boolean> havingValue(Boolean argument) { return havingValue(argument, BOOLEAN_MATCHER); }
public ManagedMongoDbLifecycleManager getStoppedServer(int port) { return selectFirst( this.servers, having(on(ManagedMongoDbLifecycleManager.class).getPort(), is(port)).and(having(on(ManagedMongoDbLifecycleManager.class).isReady(), is(false)))); }
private SelectiveMatcher findSelectiveMatcherByConnectionIdentifier( SelectiveMatcher[] selectiveMatchers) { return selectFirst( selectiveMatchers, having(on(SelectiveMatcher.class).identifier(), equalTo(identifier)).and( having(on(SelectiveMatcher.class).location(), notNullValue()))); }
public ManagedRedisLifecycleManager getStartedServer(int port) { if(this.master.getPort() == port && this.master.isReady()) { return this.master; } return selectFirst( this.slaveServers, having(on(ManagedRedisLifecycleManager.class).getPort(), is(port)).and(having(on(ManagedRedisLifecycleManager.class).isReady(), is(true)))); }
public ManagedRedisLifecycleManager getStartedServer(int port) { if(this.master.getPort() == port && this.master.isReady()) { return this.master; } return selectFirst( this.slaveServers, having(on(ManagedRedisLifecycleManager.class).getPort(), is(port)).and(having(on(ManagedRedisLifecycleManager.class).isReady(), is(true)))); }
public ManagedRedisLifecycleManager getStoppedServer(int port) { if(this.master.getPort() == port && !this.master.isReady()) { return this.master; } return selectFirst( this.slaveServers, having(on(ManagedRedisLifecycleManager.class).getPort(), is(port)).and(having(on(ManagedRedisLifecycleManager.class).isReady(), is(false)))); }
public ManagedRedisLifecycleManager getStoppedServer(int port) { if(this.master.getPort() == port && !this.master.isReady()) { return this.master; } return selectFirst( this.slaveServers, having(on(ManagedRedisLifecycleManager.class).getPort(), is(port)).and(having(on(ManagedRedisLifecycleManager.class).isReady(), is(false)))); }
this.shards, having(on(ManagedMongoDbLifecycleManager.class).getPort(), is(port)).and(having(on(ManagedMongoDbLifecycleManager.class).isReady(), is(state)))); this.configs, having(on(ManagedMongoDbLifecycleManager.class).getPort(), is(port)).and(having(on(ManagedMongoDbLifecycleManager.class).isReady(), is(state)))); this.mongos, having(on(ManagedMongoDbLifecycleManager.class).getPort(), is(port)).and(having(on(ManagedMongoDbLifecycleManager.class).isReady(), is(state)))); if(abstractLifecycleManager == null) { for (ReplicaSetManagedMongoDb replicaSetManagedMongoDb : this.replicaSets) {
this.shards, having(on(ManagedMongoDbLifecycleManager.class).getPort(), is(port)).and(having(on(ManagedMongoDbLifecycleManager.class).isReady(), is(state)))); this.configs, having(on(ManagedMongoDbLifecycleManager.class).getPort(), is(port)).and(having(on(ManagedMongoDbLifecycleManager.class).isReady(), is(state)))); this.mongos, having(on(ManagedMongoDbLifecycleManager.class).getPort(), is(port)).and(having(on(ManagedMongoDbLifecycleManager.class).isReady(), is(state)))); if(abstractLifecycleManager == null) { for (ReplicaSetManagedMongoDb replicaSetManagedMongoDb : this.replicaSets) {