Money param reorder

This commit is contained in:
Olof Larsson 2013-12-03 20:20:14 +01:00
parent 3749074463
commit 8e0362172d
4 changed files with 68 additions and 61 deletions

View File

@ -20,6 +20,10 @@ public class Money
public static String accountId(Object account)
{
// It's OK to send to or from null...
if (account == null) return null;
// ... but if something is supplied we must manage to extract an id.
String ret = MUtil.extract(String.class, "accountId", account);
if (ret == null) throw new IllegalArgumentException("extraction of accountId from object failed");
return ret;
@ -100,82 +104,82 @@ public class Money
// MOVE
public static boolean move(double amount, Object cause, Object from, Object to, Collection<String> categories)
public static boolean move(Object from, Object to, Object by, double amount, Collection<String> categories)
{
if (disabled()) return false;
return mixin.move(amount, accountId(cause), accountId(from), accountId(to), categories);
return mixin.move(accountId(from), accountId(to), accountId(by), amount, categories);
}
public static boolean move(double amount, Object cause, Object from, Object to, String... categories)
public static boolean move(Object from, Object to, Object by, double amount, String... categories)
{
if (disabled()) return false;
return mixin.move(amount, accountId(cause), accountId(from), accountId(to), categories);
return mixin.move(accountId(from), accountId(to), accountId(by), amount, categories);
}
public static boolean move(double amount, Object cause, Object from, Object to)
public static boolean move(Object from, Object to, Object by, double amount)
{
if (disabled()) return false;
return mixin.move(amount, accountId(cause), accountId(from), accountId(to));
return mixin.move(accountId(from), accountId(to), accountId(by), amount);
}
// SPAWN
public static boolean spawn(double amount, Object cause, Object to, Collection<String> categories)
public static boolean spawn(Object to, Object by, double amount, Collection<String> categories)
{
if (disabled()) return false;
return mixin.spawn(amount, accountId(cause), accountId(to), categories);
return mixin.spawn(accountId(to), accountId(by), amount, categories);
}
public static boolean spawn(double amount, Object cause, Object to, String... categories)
public static boolean spawn(Object to, Object by, double amount, String... categories)
{
if (disabled()) return false;
return mixin.spawn(amount, accountId(cause), accountId(to), categories);
return mixin.spawn(accountId(to), accountId(by), amount, categories);
}
public static boolean spawn(double amount, Object cause, Object toId)
public static boolean spawn(Object toId, Object by, double amount)
{
if (disabled()) return false;
return mixin.spawn(amount, accountId(cause), accountId(toId));
return mixin.spawn(accountId(toId), accountId(by), amount);
}
// DESPAWN
public static boolean despawn(double amount, Object cause, Object from, Collection<String> categories)
public static boolean despawn(Object from, Object by, double amount, Collection<String> categories)
{
if (disabled()) return false;
return mixin.despawn(amount, accountId(cause), accountId(from), categories);
return mixin.despawn(accountId(from), accountId(by), amount, categories);
}
public static boolean despawn(double amount, Object cause, Object from, String... categories)
public static boolean despawn(Object from, Object by, double amount, String... categories)
{
if (disabled()) return false;
return mixin.despawn(amount, accountId(cause), accountId(from), categories);
return mixin.despawn(accountId(from), accountId(by), amount, categories);
}
public static boolean despawn(double amount, Object cause, Object from)
public static boolean despawn(Object from, Object by, double amount)
{
if (disabled()) return false;
return mixin.despawn(amount, accountId(cause), accountId(from));
return mixin.despawn(accountId(from), accountId(by), amount);
}
// SET
public static boolean set(double amount, Object cause, Object account, Collection<String> categories)
public static boolean set(Object account, Object by, double amount, Collection<String> categories)
{
if (disabled()) return false;
return mixin.set(amount, accountId(cause), accountId(account), categories);
return mixin.set(accountId(account), accountId(by), amount, categories);
}
public static boolean set(double amount, Object cause, Object account, String... categories)
public static boolean set(Object account, Object by, double amount, String... categories)
{
if (disabled()) return false;
return mixin.set(amount, accountId(cause), accountId(account), categories);
return mixin.set(accountId(account), accountId(by), amount, categories);
}
public static boolean set(double amount, Object cause, Object account)
public static boolean set(Object account, Object by, double amount)
{
if (disabled()) return false;
return mixin.set(amount, accountId(cause), accountId(account));
return mixin.set(accountId(account), accountId(by), amount);
}
}

View File

@ -36,20 +36,20 @@ public interface MoneyMixin
// MODIFY
// -------------------------------------------- //
public boolean move(double amount, String causeId, String fromId, String toId, Collection<String> categories);
public boolean move(double amount, String causeId, String fromId, String toId, String... categories);
public boolean move(double amount, String causeId, String fromId, String toId);
public boolean move(String fromId, String toId, String byId, double amount, Collection<String> categories);
public boolean move(String fromId, String toId, String byId, double amount, String... categories);
public boolean move(String fromId, String toId, String byId, double amount);
public boolean spawn(double amount, String causeId, String toId, Collection<String> categories);
public boolean spawn(double amount, String causeId, String toId, String... categories);
public boolean spawn(double amount, String causeId, String toId);
public boolean spawn(String toId, String byId, double amount, Collection<String> categories);
public boolean spawn(String toId, String byId, double amount, String... categories);
public boolean spawn(String toId, String byId, double amount);
public boolean despawn(double amount, String causeId, String fromId, Collection<String> categories);
public boolean despawn(double amount, String causeId, String fromId, String... categories);
public boolean despawn(double amount, String causeId, String fromId);
public boolean despawn(String fromId, String byId, double amount, Collection<String> categories);
public boolean despawn(String fromId, String byId, double amount, String... categories);
public boolean despawn(String fromId, String byId, double amount);
public boolean set(double amount, String causeId, String accountId, Collection<String> categories);
public boolean set(double amount, String causeId, String accountId, String... categories);
public boolean set(double amount, String causeId, String accountId);
public boolean set(String accountId, String byId, double amount, Collection<String> categories);
public boolean set(String accountId, String byId, double amount, String... categories);
public boolean set(String accountId, String byId, double amount);
}

View File

@ -12,73 +12,76 @@ public abstract class MoneyMixinAbstract implements MoneyMixin
// MOVE
/*public boolean move(double amount, String causeId, String fromId, String toId, Collection<String> categories)
// this is the abstract one
/*
public boolean move(String fromId, String toId, String byId, double amount, Collection<String> categories)
{
// LOL this one shall be abstract still :3
// TODO Auto-generated method stub
return false;
}*/
public boolean move(double amount, String causeId, String fromId, String toId, String... categories)
public boolean move(String fromId, String toId, String byId, double amount, String... categories)
{
return this.move(amount, causeId, fromId, toId, Arrays.asList(categories));
return this.move(fromId, toId, byId, amount, Arrays.asList(categories));
}
public boolean move(double amount, String causeId, String fromId, String toId)
public boolean move(String fromId, String toId, String byId, double amount)
{
return this.move(amount, causeId, fromId, toId, new ArrayList<String>());
return this.move(fromId, toId, byId, amount, new ArrayList<String>());
}
// SPAWN
public boolean spawn(double amount, String causeId, String toId, Collection<String> categories)
public boolean spawn(String toId, String byId, double amount, Collection<String> categories)
{
// Based on Move
return this.move(amount, causeId, null, toId, categories);
return this.move(null, toId, byId, amount, categories);
}
public boolean spawn(double amount, String causeId, String toId, String... categories)
public boolean spawn(String toId, String byId, double amount, String... categories)
{
return this.spawn(amount, causeId, toId, Arrays.asList(categories));
return this.spawn(toId, byId, amount, Arrays.asList(categories));
}
public boolean spawn(double amount, String causeId, String toId)
public boolean spawn(String toId, String byId, double amount)
{
return this.spawn(amount, causeId, toId, new ArrayList<String>());
return this.spawn(toId, byId, amount, new ArrayList<String>());
}
// DESPAWN
public boolean despawn(double amount, String causeId, String fromId, Collection<String> categories)
public boolean despawn(String fromId, String byId, double amount, Collection<String> categories)
{
// Based on Move
return this.move(amount, causeId, fromId, null, categories);
return this.move(fromId, null, byId, amount, categories);
}
public boolean despawn(double amount, String causeId, String fromId, String... categories)
public boolean despawn(String fromId, String byId, double amount, String... categories)
{
return this.despawn(amount, causeId, fromId, Arrays.asList(categories));
return this.despawn(fromId, byId, amount, Arrays.asList(categories));
}
public boolean despawn(double amount, String causeId, String fromId)
public boolean despawn(String fromId, String byId, double amount)
{
return this.despawn(amount, causeId, fromId, new ArrayList<String>());
return this.despawn(fromId, byId, amount, new ArrayList<String>());
}
// SET
public boolean set(double amount, String causeId, String accountId, Collection<String> categories)
public boolean set(String accountId, String byId, double amount, Collection<String> categories)
{
// Based on Move
return this.move(amount - this.get(accountId), causeId, null, accountId, categories);
return this.move(null, accountId, byId, amount - this.get(accountId), categories);
}
public boolean set(double amount, String causeId, String accountId, String... categories)
public boolean set(String accountId, String byId, double amount, String... categories)
{
return this.set(amount, causeId, accountId, Arrays.asList(categories));
return this.set(accountId, byId, amount, Arrays.asList(categories));
}
public boolean set(double amount, String causeId, String accountId)
public boolean set(String accountId, String byId, double amount)
{
return this.set(amount, causeId, accountId, new ArrayList<String>());
return this.set(accountId, byId, amount, new ArrayList<String>());
}
}

View File

@ -117,7 +117,7 @@ public class MoneyMixinVault extends MoneyMixinAbstract
// -------------------------------------------- //
@Override
public boolean move(double amount, String causeId, String fromId, String toId, Collection<String> categories)
public boolean move(String fromId, String toId, String byId, double amount, Collection<String> categories)
{
// Ensure positive direction
if (amount < 0)