Skip to content

Method: getGewicht()

1: package material.auspraegungen;
2:
3: import material.Auspraegung;
4: import material.papier.Papier;
5:
6: import javax.measure.Quantity;
7: import javax.measure.quantity.Mass;
8: import java.util.Objects;
9:
10: /**
11: * Klasse, welche Papiertypen kapselt.
12: */
13: public class Papiertyp extends Auspraegung<Papier> {
14:         private final Papierformat papierformat;
15:         private final Quantity<Mass> gewicht;
16:         private final Farbe farbe;
17:         
18:         /**
19:          * Konstruktor.
20:          * @param papierformat papierformat des Papiertyp
21:          * @param gewicht gewicht des Papiertyp
22:          * @param farbe farbe des Papiertyp
23:          */
24:         public Papiertyp(final Papierformat papierformat, final Quantity<Mass> gewicht, final Farbe farbe) {
25:                 super(Papier.class);
26:                 
27:                 Objects.requireNonNull(papierformat);
28:                 Objects.requireNonNull(gewicht);
29:                 Objects.requireNonNull(farbe);
30:                 
31:                 this.papierformat = papierformat;
32:                 this.gewicht = gewicht;
33:                 this.farbe = farbe;
34:         }
35:         
36:         /**
37:          * Getter.
38:          * @return Papierformat des Papiertyp
39:          */
40:         public Papierformat getPapierformat() {
41:                 return this.papierformat;
42:         }
43:         
44:         /**
45:          * Getter.
46:          * @return Gewicht des Papiertyp
47:          */
48:         public Quantity<Mass> getGewicht() {
49:                 return this.gewicht;
50:         }
51:         
52:         /**
53:          * Getter.
54:          * @return Farbe des Papiertyp
55:          */
56:         public Farbe getFarbe() {
57:                 return this.farbe;
58:         }
59:         
60:         @Override
61:         public boolean equals(final Object o) {
62:                 if (this == o) {
63:                         return true;
64:                 }
65:                 if (o == null || this.getClass() != o.getClass()) {
66:                         return false;
67:                 }
68:                 final Papiertyp papiertyp = (Papiertyp) o;
69:                 return this.papierformat == papiertyp.papierformat
70:                                 &&        Objects.equals(this.gewicht, papiertyp.gewicht)
71:                                 &&        Objects.equals(this.farbe, papiertyp.farbe);
72:         }
73:         
74:         @Override
75:         public int hashCode() {
76:                 
77:                 return Objects.hash(this.papierformat, this.gewicht, this.farbe);
78:         }
79: }