summaryrefslogtreecommitdiffstats
path: root/Essentials/src/com/earth2me/essentials/register/payment/Method.java
blob: f8bd814ef91a5d0de24bf8117e0b4755013fec50 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
package com.earth2me.essentials.register.payment;

import org.bukkit.plugin.Plugin;


/**
 * Interface to be implemented by a payment method.
 *
 * @author Nijikokun <nijikokun@shortmail.com> (@nijikokun)
 * @copyright Copyright (C) 2011
 * @license AOL license <http://aol.nexua.org>
 */
public interface Method
{
	/**
	 * Encodes the Plugin into an Object disguised as the Plugin.
	 * If you want the original Plugin Class you must cast it to the correct
	 * Plugin, to do so you have to verify the name and or version then cast.
	 *
	 * <pre>
	 *  if(method.getName().equalsIgnoreCase("iConomy"))
	 *   iConomy plugin = ((iConomy)method.getPlugin());</pre>
	 * 
	 * @return <code>Object</code>
	 * @see #getName()
	 * @see #getVersion()
	 */
	public Object getPlugin();

	/**
	 * Returns the actual name of this method.
	 *
	 * @return <code>String</code> Plugin name.
	 */
	public String getName();

	/**
	 * Returns the actual version of this method.
	 *
	 * @return <code>String</code> Plugin version.
	 */
	public String getVersion();

	/**
	 * Returns the amount of decimal places that get stored
	 * NOTE: it will return -1 if there is no rounding
	 * 
	 * @return <code>int</code> for each decimal place
	 */
	public int fractionalDigits();

	/**
	 * Formats amounts into this payment methods style of currency display.
	 *
	 * @param amount Double
	 * @return <code>String</code> - Formatted Currency Display.
	 */
	public String format(double amount);

	/**
	 * Allows the verification of bank API existence in this payment method.
	 *
	 * @return <code>boolean</code>
	 */
	public boolean hasBanks();

	/**
	 * Determines the existence of a bank via name.
	 *
	 * @param bank Bank name
	 * @return <code>boolean</code>
	 * @see #hasBanks
	 */
	public boolean hasBank(String bank);

	/**
	 * Determines the existence of an account via name.
	 *
	 * @param name Account name
	 * @return <code>boolean</code>
	 */
	public boolean hasAccount(String name);

	/**
	 * Check to see if an account <code>name</code> is tied to a <code>bank</code>.
	 *
	 * @param bank Bank name
	 * @param name Account name
	 * @return <code>boolean</code>
	 */
	public boolean hasBankAccount(String bank, String name);

	/**
	 * Returns a <code>MethodAccount</code> class for an account <code>name</code>.
	 *
	 * @param name Account name
	 * @return <code>MethodAccount</code> <em>or</em>  <code>Null</code>
	 */
	public MethodAccount getAccount(String name);

	/**
	 * Returns a <code>MethodBankAccount</code> class for an account <code>name</code>.
	 *
	 * @param bank Bank name
	 * @param name Account name
	 * @return <code>MethodBankAccount</code> <em>or</em>  <code>Null</code>
	 */
	public MethodBankAccount getBankAccount(String bank, String name);

	/**
	 * Checks to verify the compatibility between this Method and a plugin.
	 * Internal usage only, for the most part.
	 *
	 * @param plugin Plugin
	 * @return <code>boolean</code>
	 */
	public boolean isCompatible(Plugin plugin);

	/**
	 * Set Plugin data.
	 *
	 * @param plugin Plugin
	 */
	public void setPlugin(Plugin plugin);


	/**
	 * Contains Calculator and Balance functions for Accounts.
	 */
	public interface MethodAccount
	{
		public double balance();

		public boolean set(double amount);

		public boolean add(double amount);

		public boolean subtract(double amount);

		public boolean multiply(double amount);

		public boolean divide(double amount);

		public boolean hasEnough(double amount);

		public boolean hasOver(double amount);

		public boolean hasUnder(double amount);

		public boolean isNegative();

		public boolean remove();

		@Override
		public String toString();
	}


	/**
	 * Contains Calculator and Balance functions for Bank Accounts.
	 */
	public interface MethodBankAccount
	{
		public double balance();

		public String getBankName();

		public int getBankId();

		public boolean set(double amount);

		public boolean add(double amount);

		public boolean subtract(double amount);

		public boolean multiply(double amount);

		public boolean divide(double amount);

		public boolean hasEnough(double amount);

		public boolean hasOver(double amount);

		public boolean hasUnder(double amount);

		public boolean isNegative();

		public boolean remove();

		@Override
		public String toString();
	}
}