use of java.util.function.Predicate in project RecurrentComplex by Ivorforce.
the class WorldGenStructures method planStructuresInChunk.
public static void planStructuresInChunk(Random random, ChunkPos chunkPos, WorldServer world, Biome biomeGen, @Nullable Predicate<Structure> structurePredicate) {
MixingStructureSelector<NaturalGeneration, NaturalStructureSelector.Category> structureSelector = StructureRegistry.INSTANCE.naturalStructureSelectors().get(biomeGen, world.provider);
float distanceToSpawn = distance(new ChunkPos(world.getSpawnPoint()), chunkPos);
// TODO Use STRUCTURE_TRIES
List<Pair<Structure<?>, NaturalGeneration>> generated = structureSelector.generatedStructures(random, world.getBiome(chunkPos.getBlock(0, 0, 0)), world.provider, distanceToSpawn);
generated.stream().filter(pair -> structurePredicate == null || structurePredicate.test(pair.getLeft())).forEach(pair -> planStructureInChunk(chunkPos, world, pair.getLeft(), pair.getRight(), random.nextLong()));
}
use of java.util.function.Predicate in project indy by Commonjava.
the class ValidationRequest method getSourcePaths.
public synchronized Set<String> getSourcePaths(boolean includeMetadata, boolean includeChecksums) throws PromotionValidationException {
if (requestPaths == null) {
Set<String> paths = null;
if (promoteRequest instanceof PathsPromoteRequest) {
paths = ((PathsPromoteRequest) promoteRequest).getPaths();
}
if (paths == null) {
ArtifactStore store = null;
try {
store = tools.getArtifactStore(promoteRequest.getSource());
} catch (IndyDataException e) {
throw new PromotionValidationException("Failed to retrieve source ArtifactStore: {}. Reason: {}", e, promoteRequest.getSource(), e.getMessage());
}
if (store != null) {
try {
paths = new HashSet<>();
listRecursively(store, "/", paths);
} catch (IndyWorkflowException e) {
throw new PromotionValidationException("Failed to list paths in source: {}. Reason: {}", e, promoteRequest.getSource(), e.getMessage());
}
}
}
requestPaths = paths;
}
if (!includeMetadata || !includeChecksums) {
Predicate<String> filter = (path) -> (includeMetadata || !path.matches(".+/maven-metadata\\.xml(\\.(md5|sha[0-9]+))?")) && (includeChecksums || !path.matches(".+\\.(md5|sha[0-9]+)"));
return requestPaths.stream().filter(filter).collect(Collectors.toSet());
}
return requestPaths;
}
use of java.util.function.Predicate in project jdk8u_jdk by JetBrains.
the class SerializedLambdaTest method testDirectStdNonser.
// standard MF: nonserializable supertype
public void testDirectStdNonser() throws Throwable {
MethodHandle fooMH = MethodHandles.lookup().findStatic(SerializedLambdaTest.class, "foo", predicateMT);
// Standard metafactory, non-serializable target: not serializable
CallSite cs = LambdaMetafactory.metafactory(MethodHandles.lookup(), "test", MethodType.methodType(Predicate.class), predicateMT, fooMH, stringPredicateMT);
Predicate<String> p = (Predicate<String>) cs.getTarget().invokeExact();
assertNotSerial(p, fooAsserter);
}
use of java.util.function.Predicate in project amos-ss17-alexa by c-i-ber.
the class AmosAlexaSimpleTestImpl method categoryLimitTest.
@Ignore
public void categoryLimitTest() throws IllegalAccessException, NoSuchFieldException, IOException {
newSession();
// Fetch category object 'lebensmittel' previously to be able to set it back afterwards, so that the test
// does not affect our data
List<Category> categories = DynamoDbMapper.getInstance().loadAll(Category.class);
Category category = null;
// We assume that 'lebensmittel' category exists!
for (Category cat : categories) {
if (cat.getName().equals("auto")) {
category = cat;
}
}
// Test limit info with unknown category name
testIntent("CategoryLimitInfoIntent", "Category:dsafoihdsfzzzzzssdf", "Es gibt keine Kategorie mit diesem Namen. Waehle eine andere Kategorie oder" + " erhalte eine Info zu den verfuegbaren Kategorien.");
// Test plain category name input
testIntentMatches("PlainCategoryIntent", "Category:auto", "Das Limit fuer die Kategorie auto liegt bei (.*) Euro.");
// Test limit setting
testIntent("CategoryLimitSetIntent", "Category:lebensmittel", "CategoryLimit:250", "Moechtest du das Ausgabelimit fuer die Kategorie lebensmittel wirklich auf 250 Euro setzen?");
// Setting confirmation (yes)
testIntent("AMAZON.YesIntent", "Limit fuer lebensmittel wurde gesetzt.");
// Test limit info after setting
testIntent("CategoryLimitInfoIntent", "Category:lebensmittel", "Das Limit fuer die Kategorie lebensmittel liegt bei 250.0 Euro.");
// Reset the category lebensmittel (as it was before)
List<Category> categories2 = DynamoDbMapper.getInstance().loadAll(Category.class);
for (Category c : categories2) {
DynamoDbMapper.getInstance().delete(c);
}
Predicate<Category> categoryPredicate = c -> c.getName().equals("lebensmittel");
categories2.removeIf(categoryPredicate);
LOGGER.info("Categories2: " + categories2);
for (Category c : categories2) {
DynamoDbMapper.getInstance().save(c);
}
DynamoDbMapper.getInstance().save(category);
}
use of java.util.function.Predicate in project LiveLessons by douglascraigschmidt.
the class TestDataFactory method getInput.
/**
* Return the input data in the given @a filename as an array of
* Strings.
*/
public static List<String> getInput(String filename, String splitter) {
try {
// Convert the filename into a pathname.
URI uri = ClassLoader.getSystemResource(filename).toURI();
// Open the file and get all the bytes.
String bytes = new String(Files.readAllBytes(Paths.get(uri)));
return // file into a list of strings.
Pattern.compile(splitter).splitAsStream(bytes).filter(((Predicate<String>) String::isEmpty).negate()).collect(toList());
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
Aggregations