List of usage examples for java.util.function Predicate Predicate
Predicate
From source file:com.microsoft.azure.utility.compute.VMImagesTests.java
@Test public void testVMImageListOffers() throws Exception { VirtualMachineImageResourceList vmImages = computeManagementClient.getVirtualMachineImagesOperations() .listOffers(parameters);//from ww w . java2 s.co m Assert.assertTrue("image count", vmImages.getResources().size() > 0); Assert.assertTrue("list offers contain param offer", vmImages.getResources().stream().anyMatch(new Predicate<VirtualMachineImageResource>() { @Override public boolean test(VirtualMachineImageResource virtualMachineImageResource) { return virtualMachineImageResource.getName().equalsIgnoreCase(parameters.getOffer()); } })); }
From source file:com.microsoft.azure.utility.compute.VMImagesTests.java
@Test public void testVMImageListSkus() throws Exception { VirtualMachineImageResourceList vmImages = computeManagementClient.getVirtualMachineImagesOperations() .listSkus(parameters);//from w w w . ja va 2 s .c om Assert.assertTrue("image count", vmImages.getResources().size() > 0); Assert.assertTrue("list offers contain param offer", vmImages.getResources().stream().anyMatch(new Predicate<VirtualMachineImageResource>() { @Override public boolean test(VirtualMachineImageResource virtualMachineImageResource) { return virtualMachineImageResource.getName().equalsIgnoreCase(parameters.getSkus()); } })); }
From source file:dk.dma.ais.packet.AisPacketFiltersStateful.java
/** * Return false if this message is known to be related to a target with an navstat different to the rhs parameter. * /*w w w. ja v a 2s .c o m*/ * @param operator * @param rhsNavstat * @return */ public Predicate<AisPacket> filterOnTargetNavigationalStatus(final CompareToOperator operator, Integer rhsNavstat) { final int navstat = rhsNavstat; return new Predicate<AisPacket>() { public boolean test(AisPacket p) { aisPacketStream.add(p); // Update state final int mmsi = getMmsi(p); // Get MMSI in question final int lhsNavstat = getNavstat(mmsi); // Extract navstat - if we know it return lhsNavstat < 0 ? false : compare(lhsNavstat, navstat, operator); } public String toString() { return "navstat = " + navstat; } }; }
From source file:dk.dma.ais.packet.AisPacketFiltersStateful.java
/** * Return false if this message is known to be related to a target with a navstat outside the given range. */// www.j av a 2 s . co m public Predicate<AisPacket> filterOnTargetNavigationalStatus(final int min, final int max) { return new Predicate<AisPacket>() { public boolean test(AisPacket p) { aisPacketStream.add(p); // Update state final int mmsi = getMmsi(p); // Get MMSI in question final int navstat = getNavstat(mmsi); // Extract IMO no. - if we know it return navstat < 0 ? false : inRange(min, max, navstat); } public String toString() { return "imo in " + min + ".." + max; } }; }
From source file:dk.dma.ais.packet.AisPacketFiltersStateful.java
/** * Return false if this message is known to be related to a target with a navstat outside the given list. */// w ww . ja v a 2s. c o m public Predicate<AisPacket> filterOnTargetNavigationalStatus(Integer[] navstats) { final int[] list = ArrayUtils.toPrimitive(navstats); Arrays.sort(list); return new Predicate<AisPacket>() { public boolean test(AisPacket p) { aisPacketStream.add(p); // Update state final int mmsi = getMmsi(p); // Get MMSI in question final int navstat = getNavstat(mmsi); // Extract navstat no. - if we know it return navstat < 0 ? false : Arrays.binarySearch(list, navstat) >= 0; } public String toString() { return "navstat in " + skipBrackets(Arrays.toString(list)); } }; }
From source file:dk.dma.ais.packet.AisPacketFiltersStateful.java
/** * Return false if this message is known to be related to a target with a SOG comparing false to 'sog'. * //from www . j a v a 2s . c o m * @param operator * @param sog * @return */ public Predicate<AisPacket> filterOnTargetSpeedOverGround(final CompareToOperator operator, Float sog) { final float rhsSog = sog; return new Predicate<AisPacket>() { public boolean test(AisPacket p) { aisPacketStream.add(p); // Update state final int mmsi = getMmsi(p); // Get MMSI in question final float lhsSog = getSog(mmsi); // Extract sog - if we know it return lhsSog != lhsSog /* NaN */ ? false : compare(lhsSog, rhsSog, operator); } public String toString() { return "sog " + operator + " " + rhsSog; } }; }
From source file:dk.dma.ais.packet.AisPacketFiltersStateful.java
/** * Return false if this message is known to be related to a target with a SOG outside the given range. *///from www . ja v a2 s . c o m public Predicate<AisPacket> filterOnTargetSpeedOverGround(final float min, final float max) { return new Predicate<AisPacket>() { public boolean test(AisPacket p) { aisPacketStream.add(p); // Update state final int mmsi = getMmsi(p); // Get MMSI in question final float lhsSog = getSog(mmsi); // Extract sog - if we know it return lhsSog != lhsSog /* NaN */ ? false : inRange(min, max, lhsSog); } public String toString() { return "sog in " + min + ".." + max; } }; }
From source file:com.thoughtworks.go.server.service.ConfigSaveDeadlockDetectionIntegrationTest.java
private Thread configRepoDeleteThread(final ConfigRepoConfig configRepoToBeDeleted, final int counter) throws InterruptedException { return createThread(new Runnable() { @Override/*www .j a v a2s . com*/ public void run() { goConfigService.updateConfig(new UpdateConfigCommand() { @Override public CruiseConfig update(CruiseConfig cruiseConfig) throws Exception { ConfigRepoConfig repoConfig = cruiseConfig.getConfigRepos().stream() .filter(new Predicate<ConfigRepoConfig>() { @Override public boolean test(ConfigRepoConfig item) { return configRepoToBeDeleted.getMaterialConfig() .equals(item.getMaterialConfig()); } }).findFirst().orElse(null); cruiseConfig.getConfigRepos().remove(repoConfig); return cruiseConfig; } }); } }, "config-repo-delete-thread" + counter); }