com.github.zaza.allegro.Item Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of allegro-client Show documentation
Show all versions of allegro-client Show documentation
Java client for Allegro Web API
package com.github.zaza.allegro;
import java.util.Arrays;
import java.util.Calendar;
import com.allegro.webapi.ArrayOfPhotoinfotype;
import com.allegro.webapi.ArrayOfPriceinfotype;
import com.allegro.webapi.ItemInfo;
import com.allegro.webapi.ItemsListType;
import com.allegro.webapi.UserInfoType;
import com.google.common.base.Objects;
public class Item {
private ItemsListType itemsListType;
private ItemInfo itemInfo;
public Item(ItemsListType itemsListType, ItemInfo itemInfo) {
this.itemsListType = itemsListType;
this.itemInfo = itemInfo;
}
public String getItemTitle() {
return itemsListType.getItemTitle();
}
public long getItemId() {
return itemsListType.getItemId();
}
public UserInfoType getSellerInfo() {
return itemsListType.getSellerInfo();
}
public ArrayOfPriceinfotype getPriceInfo() {
return itemsListType.getPriceInfo();
}
public String getTimeToEnd() {
return itemsListType.getTimeToEnd();
}
public Calendar getEndingTime() {
return itemsListType.getEndingTime();
}
public ArrayOfPhotoinfotype getPhotosInfo() {
return itemsListType.getPhotosInfo();
}
int getCategoryId() {
return itemsListType.getCategoryId();
}
public boolean isNew() {
return Condition.valueOf(itemsListType.getConditionInfo().toUpperCase()) == Condition.NEW;
}
public boolean isUsed() {
return !isNew();
}
public String getLocation() {
return itemInfo.getItLocation();
}
public String getState() {
return State.valueOf(itemInfo.getItState()).name();
}
public double lowestPrice() {
return Arrays.asList(getPriceInfo().getItem()).stream().mapToDouble(p -> p.getPriceValue()).min().getAsDouble();
}
public double highestPrice() {
return Arrays.asList(getPriceInfo().getItem()).stream().mapToDouble(p -> p.getPriceValue()).max().getAsDouble();
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (obj == this) {
return true;
}
if (obj.getClass() != getClass()) {
return false;
}
Item other = (Item) obj;
return Objects.equal(this.itemsListType, other.itemsListType) && Objects.equal(this.itemInfo, other.itemInfo);
}
@Override
public int hashCode() {
return Objects.hashCode(itemsListType, itemInfo);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy