Package org.multibit.mbm.client.interfaces.rest.api.representations.hal.supplier

Source Code of org.multibit.mbm.client.interfaces.rest.api.representations.hal.supplier.SupplierRepresentation

package org.multibit.mbm.client.interfaces.rest.api.representations.hal.supplier;

import com.google.common.base.Preconditions;
import com.theoryinpractise.halbuilder.DefaultRepresentationFactory;
import com.theoryinpractise.halbuilder.api.Representation;
import org.multibit.mbm.client.domain.model.model.Supplier;

/**
* <p>Representation to provide the following to {@link org.multibit.mbm.client.domain.model.model.Supplier}:</p>
* <ul>
* <li>Creates {@link Representation} representations</li>
* </ul>
*
* @since 0.0.1
*/
public class SupplierRepresentation {

  public Representation get(Supplier supplier) {
    Preconditions.checkNotNull(supplier, "supplier");
    Preconditions.checkNotNull(supplier.getId(), "id");

    String basePath = "/suppliers/" + supplier.getId();

    // Create top-level resource
    return new DefaultRepresentationFactory()
      .newRepresentation(basePath)
      .withLink("user","/users/" + supplier.getUser().getId());
  }

}
TOP

Related Classes of org.multibit.mbm.client.interfaces.rest.api.representations.hal.supplier.SupplierRepresentation

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.