@Test public void test() throws NoSuchMethodException { final List<Reference> references = Arrays.asList( new Reference( "xyz", ReferenceType.CODE ), new Reference( "abc", ReferenceType.ID ), new Reference( "def", ReferenceType.CODE ) ); final Object key = generator.generate( target, generator.getClass().getMethod( "toString" ), references ); Assert.assertEquals( "toString,CODE#def,CODE#xyz,ID#abc", key ); }
@Override @Nonnull public Object generate( @Nonnull Object target, @Nonnull Method method, @Nonnull Object... params ) { @SuppressWarnings( "unchecked" ) final Collection<Reference> references = (Collection<Reference>) params[0]; final SortedSet<String> referenceStrings = references.stream().map( Reference::toCacheString ) .collect( Collectors.toCollection( TreeSet::new ) ); final StringBuilder sb = new StringBuilder( method.getName() ); for ( final String string : referenceStrings ) { sb.append( ',' ).append( string ); } return sb.toString(); }
ReferenceCollectionKeyGenerator implements KeyGenerator { @Override @Nonnull public Object generate( @Nonnull Object target, @Nonnull Method method, @Nonnull Object... params ) { @SuppressWarnings( "unchecked" ) final Collection<Reference> references = (Collection<Reference>) params[0]; final SortedSet<String> referenceStrings = references.stream().map( Reference::toCacheString ) .collect( Collectors.toCollection( TreeSet::new ) ); final StringBuilder sb = new StringBuilder( method.getName() ); for ( final String string : referenceStrings ) { sb.append( ',' ).append( string ); } return sb.toString(); } }
ReferenceCollectionKeyGenerator implements KeyGenerator { @Override @Nonnull public Object generate( @Nonnull Object target, @Nonnull Method method, @Nonnull Object... params ) { @SuppressWarnings( "unchecked" ) final Collection<Reference> references = (Collection<Reference>) params[0]; final SortedSet<String> referenceStrings = references.stream().map( Reference::toCacheString ) .collect( Collectors.toCollection( TreeSet::new ) ); final StringBuilder sb = new StringBuilder( method.getName() ); for ( final String string : referenceStrings ) { sb.append( ',' ).append( string ); } return sb.toString(); }  }
ReferenceCollectionKeyGenerator implements KeyGenerator { @Override @Nonnull public Object generate( @Nonnull Object target, @Nonnull Method method, @Nonnull Object... params ) { @SuppressWarnings( "unchecked" ) final Collection<Reference> references = (Collection<Reference>) params[0]; final SortedSet<String> referenceStrings = references.stream().map( Reference::toCacheString ) .collect( Collectors.toCollection( TreeSet::new ) ); final StringBuilder sb = new StringBuilder( method.getName() ); for ( final String string : referenceStrings ) { sb.append( ',' ).append( string ); } return sb.toString(); }  @Override @Nonnull Object generate( @Nonnull Object target, @Nonnull Method method, @Nonnull Object... params ); }
ReferenceCollectionKeyGenerator implements KeyGenerator { @Override @Nonnull public Object generate( @Nonnull Object target, @Nonnull Method method, @Nonnull Object... params ) { @SuppressWarnings( "unchecked" ) final Collection<Reference> references = (Collection<Reference>) params[0]; final SortedSet<String> referenceStrings = references.stream().map( Reference::toCacheString ) .collect( Collectors.toCollection( TreeSet::new ) ); final StringBuilder sb = new StringBuilder( method.getName() ); for ( final String string : referenceStrings ) { sb.append( ',' ).append( string ); } return sb.toString(); }  @Override @Nonnull Object generate( @Nonnull Object target, @Nonnull Method method, @Nonnull Object... params );  }