@Override public Representation toRepresentation(Object source, Variant target, Resource resource) { Representation result = null; if (source instanceof JacksonRepresentation) { result = (JacksonRepresentation<?>) source; } else { if (target.getMediaType() == null) { target.setMediaType(MediaType.APPLICATION_JSON); } if (isCompatible(target)) { result = create(target.getMediaType(), source); } } return result; }
@Override public Representation toRepresentation(Object source, Variant target, Resource resource) { Representation result = null; if (source instanceof JacksonRepresentation) { result = (JacksonRepresentation<?>) source; } else { if (target.getMediaType() == null) { target.setMediaType(MediaType.APPLICATION_JSON); } if (isCompatible(target)) { result = create(target.getMediaType(), source); } } return result; }
@Override public Representation toRepresentation( Object source, Variant target, Resource resource ) { Representation result = null; if( source instanceof JsonRepresentation ) { result = (JsonRepresentation<?>) source; } else { if( target.getMediaType() == null ) { target.setMediaType( MediaType.APPLICATION_JSON ); } if( isCompatible( target ) ) { result = create( target.getMediaType(), source ); } } return result; }
/** * Converts the given JAX-RS Variants to Restlet Variants. * * @param jaxRsVariants * @return the List of Restlet Variants */ public static List<org.restlet.representation.Variant> toRestletVariants( Collection<javax.ws.rs.core.Variant> jaxRsVariants) { final List<org.restlet.representation.Variant> restletVariants = new ArrayList<org.restlet.representation.Variant>( jaxRsVariants.size()); for (final javax.ws.rs.core.Variant jaxRsVariant : jaxRsVariants) { final org.restlet.representation.Variant restletVariant = new org.restlet.representation.Variant(); restletVariant.setCharacterSet(getRestletCharacterSet(jaxRsVariant .getMediaType())); restletVariant.setEncodings(Util.createList(Encoding .valueOf(jaxRsVariant.getEncoding()))); restletVariant.setLanguages(Util.createList(toLanguage(jaxRsVariant .getLanguage()))); restletVariant.setMediaType(toRestletMediaType(jaxRsVariant .getMediaType())); restletVariants.add(restletVariant); } return restletVariants; }
variant.setMediaType((MediaType) current); } else if (current instanceof CharacterSet) { variant.setCharacterSet((CharacterSet) current); variant.setMediaType(defaultMediaType);