Java Code Examples for org.springframework.hateoas.Identifiable

The following examples show how to use org.springframework.hateoas.Identifiable. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
/**
 * Creates a new ToAttributedValueConverter instance.
 * 
 * @param mapper the mapper in use
 * @param reflectionProvider the reflection provider in use
 * @param lookup the converter lookup in use
 * @param valueFieldName the field defining the tag's value (may be null)
 * @param valueDefinedIn the type defining the field
 */
public IdentifiableToIdConverter(
    final Class<Identifiable<?>> type, final Mapper mapper, final ReflectionProvider reflectionProvider,
    final ConverterLookup lookup, final String valueFieldName, Class<?> valueDefinedIn) {
    this.type = type;

       Field field = null;
       try {
           field = (valueDefinedIn != null ? valueDefinedIn : type.getSuperclass())
               .getDeclaredField("id");
          
           if (!field.isAccessible()) {
               field.setAccessible(true);
           }
       } catch (NoSuchFieldException e) {
           throw new IllegalArgumentException(e.getMessage() + ": " + valueFieldName);
       }
}
 
Example 2
Source Project: hawkbit   Source File: AbstractTagToken.java    License: Eclipse Public License 1.0 5 votes vote down vote up
protected boolean checkAssignmentResult(final List<? extends Identifiable<Long>> assignedEntities,
        final Long expectedAssignedEntityId) {
    if (!CollectionUtils.isEmpty(assignedEntities) && expectedAssignedEntityId != null) {
        final List<Long> assignedDsIds = assignedEntities.stream().map(Identifiable::getId)
                .collect(Collectors.toList());
        if (assignedDsIds.contains(expectedAssignedEntityId)) {
            return true;
        }
    }
    return false;
}
 
Example 3
public void marshal(final Object source, final HierarchicalStreamWriter writer,
    final MarshallingContext context) {
    if(source instanceof Identifiable){
    	writer.setValue(((Identifiable<?>)source).getId().toString());
    }
}
 
Example 4
@Override
public void serialize(Identifiable<?> value, JsonGenerator jgen, SerializerProvider provider) 
  throws IOException, JsonProcessingException {
	provider.defaultSerializeValue(value.getId(), jgen);
}
 
Example 5
Source Project: hawkbit   Source File: AbstractTagToken.java    License: Eclipse Public License 1.0 4 votes vote down vote up
protected boolean checkUnassignmentResult(final Identifiable<Long> unAssignedEntity,
        final Long expectedUnAssignedEntityId) {
    return unAssignedEntity != null && expectedUnAssignedEntityId != null
            && unAssignedEntity.getId().equals(expectedUnAssignedEntityId);
}
 
Example 6
/**
 * Creates a new ToAttributedValueConverter instance.
 * 
 * @param mapper the mapper in use
 * @param reflectionProvider the reflection provider in use
 * @param lookup the converter lookup in use
 * @param valueFieldName the field defining the tag's value (may be null)
 */
public IdentifiableToIdConverter(
    final Class<Identifiable<?>> type, final Mapper mapper, final ReflectionProvider reflectionProvider,
    final ConverterLookup lookup, final String valueFieldName) {
    this(type, mapper, reflectionProvider, lookup, valueFieldName, null);
}