Skip to content

Instantly share code, notes, and snippets.

@renanpalmeira
Created March 14, 2019 18:27
Show Gist options
  • Save renanpalmeira/44360221556a0e273fba3d349680ec0f to your computer and use it in GitHub Desktop.
Save renanpalmeira/44360221556a0e273fba3d349680ec0f to your computer and use it in GitHub Desktop.
@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