joelhockey / jacknji11

Java Native Interface for PKCS#11
MIT License
33 stars 22 forks source link

Add equals and hashCode to CKA to enable usage in java stream #43

Closed primetomas closed 3 years ago

primetomas commented 3 years ago

By adding equals and hashCode to CKA we can use java streams for some cool operations like:

    final List<CKA> ckasAsList = Arrays.stream(ckas).collect(toList());
    final List<Long> objectRefsFromCache = cache.stream()
            .map(attribute -> attribute.objectRef)
            .distinct()
            .filter(objectRef -> hasAllAttributes(objectRef, ckasAsList))
            .collect(toList());