Created
March 14, 2019 18:27
-
-
Save renanpalmeira/44360221556a0e273fba3d349680ec0f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Data | |
@AllArgsConstructor | |
class Product { | |
private Long codigoEmpresa; | |
private Long codigoProduto; | |
} | |
@Test | |
public void test() { | |
Long filterCodigoEmpresa = 1L; | |
List<Product> products = Arrays.asList( | |
new Product(1L, 1L), | |
new Product(1L, 2L), | |
new Product(2L, 3L), | |
new Product(2L, 4L), | |
new Product(1L, 5L), | |
new Product(1L, 6L) | |
); | |
List<Product> productsByFilter = products | |
.stream() | |
.filter(product -> product.getCodigoEmpresa() == filterCodigoEmpresa) | |
.collect(Collectors.toList()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment