Skip to content

Method: create(Material, Quantity)

1: package material;
2:
3: import javax.measure.Quantity;
4: import java.util.Objects;
5:
6: /**
7: * Ein Material gemessen in der dazugehörigen Einheit.
8: *
9: * @param <Q> Die Einheit, in der gemessen wird.
10: */
11: public final class MaterialMitMessung<Q extends Quantity<Q>> {
12:         
13:         private final Quantity<Q> messung;
14:         private final Material<Q> material;
15:         
16:         private MaterialMitMessung(final Material<Q> material, final Quantity<Q> messung) {
17:                 this.messung = messung;
18:                 this.material = material;
19:         }
20:         
21:         /**
22:          * Erstellt ein MaterialMitMessung aus einem Material und einer Messung.
23:          * @param material Material
24:          * @param messung Messung
25:          * @param <R> Einheit in welcher das Material gemessen wird.
26:          * @return erstelltes MaterialMitMessung
27:          */
28:         public static <R extends Quantity<R>> MaterialMitMessung<R> create(final Material<R> material, final Quantity<R> messung) {
29:                 return new MaterialMitMessung<>(material, messung);
30:         }
31:         
32:         /**
33:          * Getter.
34:          * @return Messung des MaterialsMitMessung
35:          */
36:         public Quantity<Q> getMessung() {
37:                 return this.messung;
38:         }
39:
40:         /**
41:          * Getter.
42:          * @return Material des MaterialsMitMessung
43:          */
44:         public Material<Q> getMaterial() {
45:                 return this.material;
46:         }
47:         
48:         @Override
49:         public boolean equals(final Object o) {
50:                 if (this == o) {
51:                         return true;
52:                 }
53:                 if (o == null || this.getClass() != o.getClass()) {
54:                         return false;
55:                 }
56:                 final MaterialMitMessung<?> that = (MaterialMitMessung<?>) o;
57:                 return Objects.equals(this.messung, that.messung)
58:                                 && Objects.equals(this.material, that.material);
59:         }
60:         
61:         @Override
62:         public int hashCode() {
63:                 return Objects.hash(this.messung, this.material);
64:         }
65: }