Class Product
java.lang.Object
us.teaminceptus.novaconomy.api.util.Product
- All Implemented Interfaces:
Comparable<Product>,ConfigurationSerializable
- Direct Known Subclasses:
BusinessProduct
Represents a Sellable Product
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintstatic @Nullable Productdeserialize(@Nullable Map<String, Object> serial) Deserializes a Product into a Map.boolean@org.jetbrains.annotations.NotNull doubleFetches the Product's Price Amount.@Nullable EconomyFetches the Product's Economy.@NotNull ItemStackgetItem()Fetches the Product's Item.@NotNull PricegetPrice()Fetches the Product's Price.inthashCode()@NotNull ProductSets the Product's Selling Item.@NotNull ProductSets the Proudct's selling price.toEntry()Converts this Product to an immutable Map Entry.toString()
-
Constructor Details
-
Product
public Product(@NotNull @NotNull ItemStack item, @NotNull @NotNull Price price) throws IllegalArgumentException Constructs a Product.- Parameters:
item- Item to sellprice- Price to sell at- Throws:
IllegalArgumentException- if item or price is null
-
Product
Constructs a Product from a Business Product.- Parameters:
product- Business Product to construct from- Throws:
NullPointerException- if product is null
-
Product
public Product(@NotNull @NotNull ItemStack item, @NotNull @NotNull Economy econ, double amount) throws IllegalArgumentException Constructs a Product.- Parameters:
item- Item to sellecon- Economy to sell atamount- Price at selling- Throws:
IllegalArgumentException- if item, price, or economy is null / amount is less than or greater than 0
-
-
Method Details
-
getItem
Fetches the Product's Item.- Returns:
- Product Item selling
-
setItem
@NotNull public @NotNull Product setItem(@NotNull @NotNull ItemStack item) throws IllegalArgumentException Sets the Product's Selling Item.- Parameters:
item- Item to sell- Returns:
- this Product, for chaining
- Throws:
IllegalArgumentException- if item is null
-
getPrice
Fetches the Product's Price.- Returns:
- Price Product is selling at
-
getEconomy
Fetches the Product's Economy.- Returns:
- Economy Product is purchased with
-
getAmount
@NotNull public @org.jetbrains.annotations.NotNull double getAmount()Fetches the Product's Price Amount.- Returns:
- Price Amount Product is selling at
-
toEntry
Converts this Product to an immutable Map Entry.- Returns:
- Immutable Map Entry
-
setPrice
@NotNull public @NotNull Product setPrice(@NotNull @NotNull Price price) throws IllegalArgumentException Sets the Proudct's selling price.- Parameters:
price- Price Selling at- Returns:
- this Product, for chaining
- Throws:
IllegalArgumentException- if Price is null
-
serialize
- Specified by:
serializein interfaceConfigurationSerializable
-
equals
-
hashCode
public int hashCode() -
toString
-
deserialize
@Nullable public static @Nullable Product deserialize(@Nullable @Nullable Map<String, Object> serial) throws IllegalArgumentExceptionDeserializes a Product into a Map.- Parameters:
serial- Serialization fromserialize()- Returns:
- Deserialized Product, or null if serial is null
- Throws:
IllegalArgumentException- if a part is missing or malformed
-
compareTo
- Specified by:
compareToin interfaceComparable<Product>
-