本文整理匯總了Java中org.springframework.hateoas.core.EmbeddedWrapper類的典型用法代碼示例。如果您正苦於以下問題:Java EmbeddedWrapper類的具體用法?Java EmbeddedWrapper怎麽用?Java EmbeddedWrapper使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
EmbeddedWrapper類屬於org.springframework.hateoas.core包,在下文中一共展示了EmbeddedWrapper類的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getDefaultedRelFor
import org.springframework.hateoas.core.EmbeddedWrapper; //導入依賴的package包/類
private String getDefaultedRelFor(EmbeddedWrapper wrapper, boolean forCollection) {
String valueRel = wrapper.getRel();
if (StringUtils.hasText(valueRel)) {
return valueRel;
}
if (provider == null) {
return DEFAULT_REL;
}
Class<?> type = wrapper.getRelTargetType();
if (type == null) {
throw new IllegalStateException(String.format(INVALID_EMBEDDED_WRAPPER, wrapper));
}
String rel = forCollection ? provider.getCollectionResourceRelFor(type) : provider.getItemResourceRelFor(type);
if (curieProvider != null) {
rel = curieProvider.getNamespacedRelFor(rel);
}
return rel == null ? DEFAULT_REL : rel;
}
示例2: instantiateResource
import org.springframework.hateoas.core.EmbeddedWrapper; //導入依賴的package包/類
@Override
protected FooResource instantiateResource(Foo entity) {
BarResource bar1 = new BarResourceAssembler().toResource(new Bar(Url62.decode("bar1"), "bar one", entity));
BarResource bar2 = new BarResourceAssembler().toResource(new Bar(Url62.decode("bar2"), "bar two", entity));
EmbeddedWrappers wrappers = new EmbeddedWrappers(true);
List<EmbeddedWrapper> embeddeds = Arrays.asList(wrappers.wrap(bar1), wrappers.wrap(bar2));
FooResource fooResource = new FooResource(entity.getId(), entity.getName());
fooResource.setEmbeddeds(new Resources(embeddeds));
return fooResource;
}
示例3: add
import org.springframework.hateoas.core.EmbeddedWrapper; //導入依賴的package包/類
/**
* Adds the given value to the embeddeds. Will skip doing so if the value is {@literal null} or the content of a
* {@link Resource} is {@literal null}.
*
* @param source can be {@literal null}.
*/
public void add(Object source) {
EmbeddedWrapper wrapper = wrappers.wrap(source);
if (wrapper == null) {
return;
}
String collectionRel = getDefaultedRelFor(wrapper, true);
String collectionOrItemRel = collectionRel;
if (!embeddeds.containsKey(collectionRel)) {
collectionOrItemRel = getDefaultedRelFor(wrapper, wrapper.isCollectionValue());
}
Object currentValue = embeddeds.get(collectionOrItemRel);
Object value = wrapper.getValue();
if (currentValue == null && !wrapper.isCollectionValue()) {
embeddeds.put(collectionOrItemRel, value);
return;
}
List<Object> list = new ArrayList<Object>();
list.addAll(asCollection(currentValue));
list.addAll(asCollection(wrapper.getValue()));
embeddeds.remove(collectionOrItemRel);
embeddeds.put(collectionRel, list);
}
示例4: getEmbeddeds
import org.springframework.hateoas.core.EmbeddedWrapper; //導入依賴的package包/類
public Resources<EmbeddedWrapper> getEmbeddeds() {
return embeddeds;
}
示例5: setEmbeddeds
import org.springframework.hateoas.core.EmbeddedWrapper; //導入依賴的package包/類
public void setEmbeddeds(Resources<EmbeddedWrapper> embeddeds) {
this.embeddeds = embeddeds;
}
示例6: ProfileResource
import org.springframework.hateoas.core.EmbeddedWrapper; //導入依賴的package包/類
public ProfileResource(String firstName, String lastName, Resources<EmbeddedWrapper> embeddeds) {
this.firstName = firstName;
this.lastName = lastName;
this.embeddeds = embeddeds;
}
示例7: getEmbeddeds
import org.springframework.hateoas.core.EmbeddedWrapper; //導入依賴的package包/類
public Resources<EmbeddedWrapper> getEmbeddeds() {
return embeddeds;
}