Skip to content

Method: getCapacity()

1: package de.fhdw.gaming.ipspiel23.memory;
2:
3:
4: /**
5: * Implements {@link IGameMemoryCapacity}.
6: */
7: public final class GameMemoryCapacity implements IGameMemoryCapacity {
8:
9: /**
10: * True when the default capacity is used. Currently 5.
11: * Have to call it "v" because of pmd.
12: */
13: private final boolean vDefault;
14:
15: /**
16: * True when the capacity is unlimited.
17: * Have to call it "v" because of pmd.
18: */
19: private final boolean vUnlimited;
20:
21: /**
22: * Capacity of the memory. -1 if it's unlimited.
23: */
24: private final int capacity;
25:
26: /**
27: * private Constructor.
28: * @param isDefault default.
29: * @param isUnlimited unlimited capacity.
30: * @param capacity Custom capacity.
31: */
32: private GameMemoryCapacity(final boolean isDefault, final boolean isUnlimited, final int capacity) {
33: this.vDefault = isDefault;
34: this.vUnlimited = isUnlimited;
35: this.capacity = capacity;
36: }
37:
38: /**
39: * unlimited memory capacity.
40: */
41: public static IGameMemoryCapacity unlimited() {
42: return new GameMemoryCapacity(false, true, -1);
43: }
44:
45: /**
46: * use the specified capacity.
47: * @param capacity t.
48: */
49: public static IGameMemoryCapacity of(final Integer capacity) {
50: return new GameMemoryCapacity(false, false, capacity);
51: }
52:
53: /**
54: * Uses a default capacity. Default is capacity of 5.
55: */
56: public static IGameMemoryCapacity useDefault() {
57: return new GameMemoryCapacity(true, false, 5);
58: }
59:
60: @Override
61: public boolean isUnlimited() {
62: return this.vUnlimited;
63: }
64:
65: @Override
66: public boolean isDefault() {
67: return this.vDefault;
68: }
69:
70: @Override
71: public int getCapacity() {
72: return this.capacity;
73: }
74: }