Examples of EmbeddedWrapper


Examples of org.springframework.hateoas.core.EmbeddedWrapper

  @Before
  public void setUp() {

    EmbeddedWrappers wrappers = new EmbeddedWrappers(false);
    EmbeddedWrapper wrapper = wrappers.wrap("Embedded", "foo");
    this.resources = new Resources<EmbeddedWrapper>(Collections.singleton(wrapper));
  }
View Full Code Here

Examples of org.springframework.hateoas.core.EmbeddedWrapper

   *
   * @param value 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);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.