Making argument index optional and heavy OCD

This commit is contained in:
Olof Larsson 2013-03-14 12:35:42 +01:00
parent 92ac999c2e
commit ad06dd854c
31 changed files with 302 additions and 171 deletions

View File

@ -491,9 +491,9 @@ public abstract class MCommand
return this.args.get(idx); return this.args.get(idx);
} }
public <T> T arg(int idx, ArgReader<T> ar) public <T> T arg(int idx, ArgReader<T> argReader)
{ {
return this.arg(idx, ar, null); return this.arg(idx, argReader, null);
} }
public <T> T arg(int idx, ArgReader<T> argReader, T defaultNotSet) public <T> T arg(int idx, ArgReader<T> argReader, T defaultNotSet)
@ -504,4 +504,11 @@ public abstract class MCommand
if (result.hasErrors()) this.msg(result.getErrors()); if (result.hasErrors()) this.msg(result.getErrors());
return result.getResult(); return result.getResult();
} }
public <T> T arg(ArgReader<T> argReader)
{
ArgResult<T> result = argReader.read(this.sender);
if (result.hasErrors()) this.msg(result.getErrors());
return result.getResult();
}
} }

View File

@ -2,11 +2,19 @@ package com.massivecraft.mcore.cmd.arg;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
public abstract class ARAbstractPrimitive<T> implements ArgReader<T> public abstract class ARAbstractPrimitive<T> extends ArgReaderAbstract<T>
{ {
// -------------------------------------------- //
// ABSTRACT
// -------------------------------------------- //
public abstract String typename(); public abstract String typename();
public abstract T convert(String arg) throws Exception; public abstract T convert(String arg) throws Exception;
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override @Override
public ArgResult<T> read(String arg, CommandSender sender) public ArgResult<T> read(String arg, CommandSender sender)
{ {

View File

@ -6,13 +6,21 @@ import org.bukkit.command.CommandSender;
import com.massivecraft.mcore.util.Txt; import com.massivecraft.mcore.util.Txt;
public abstract class ARAbstractSelect<T> implements ArgReader<T> public abstract class ARAbstractSelect<T> extends ArgReaderAbstract<T>
{ {
// -------------------------------------------- //
// ABSTRACT
// -------------------------------------------- //
public abstract String typename(); public abstract String typename();
public abstract T select(String str, CommandSender sender); public abstract T select(String str, CommandSender sender);
public abstract Collection<String> altNames(CommandSender sender); public abstract Collection<String> altNames(CommandSender sender);
public boolean canList(CommandSender sender) { return true; } public boolean canList(CommandSender sender) { return true; }
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override @Override
public ArgResult<T> read(String arg, CommandSender sender) public ArgResult<T> read(String arg, CommandSender sender)
{ {

View File

@ -10,6 +10,17 @@ import com.massivecraft.mcore.usys.AspectColl;
public class ARAspect extends ARAbstractSelect<Aspect> public class ARAspect extends ARAbstractSelect<Aspect>
{ {
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
private static ARAspect i = new ARAspect();
public static ARAspect get() { return i; }
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override @Override
public String typename() public String typename()
{ {
@ -34,11 +45,4 @@ public class ARAspect extends ARAbstractSelect<Aspect>
return AspectColl.i.getIds(); return AspectColl.i.getIds();
} }
// -------------------------------------------- //
// INSTANCE
// -------------------------------------------- //
private static ARAspect i = new ARAspect();
public static ARAspect get() { return i; }
} }

View File

@ -2,6 +2,17 @@ package com.massivecraft.mcore.cmd.arg;
public class ARBoolean extends ARAbstractPrimitive<Boolean> public class ARBoolean extends ARAbstractPrimitive<Boolean>
{ {
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
private static ARBoolean i = new ARBoolean();
public static ARBoolean get() { return i; }
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override @Override
public String typename() public String typename()
{ {
@ -19,11 +30,4 @@ public class ARBoolean extends ARAbstractPrimitive<Boolean>
return false; return false;
} }
// -------------------------------------------- //
// INSTANCE
// -------------------------------------------- //
private static ARBoolean i = new ARBoolean();
public static ARBoolean get() { return i; }
} }

View File

@ -1,7 +1,18 @@
package com.massivecraft.mcore.cmd.arg; package com.massivecraft.mcore.cmd.arg;
public class ARByte extends ARAbstractPrimitive<Byte> public class ARByte extends ARAbstractPrimitive<Byte>
{ {
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
private static ARByte i = new ARByte();
public static ARByte get() { return i; }
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override @Override
public String typename() public String typename()
{ {
@ -14,11 +25,4 @@ public class ARByte extends ARAbstractPrimitive<Byte>
return Byte.parseByte(arg); return Byte.parseByte(arg);
} }
// -------------------------------------------- //
// INSTANCE
// -------------------------------------------- //
private static ARByte i = new ARByte();
public static ARByte get() { return i; }
} }

View File

@ -9,6 +9,17 @@ import org.bukkit.command.CommandSender;
public class ARChatColor extends ARAbstractSelect<ChatColor> public class ARChatColor extends ARAbstractSelect<ChatColor>
{ {
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
private static ARChatColor i = new ARChatColor();
public static ARChatColor get() { return i; }
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override @Override
public String typename() public String typename()
{ {
@ -62,11 +73,4 @@ public class ARChatColor extends ARAbstractSelect<ChatColor>
return str; return str;
} }
// -------------------------------------------- //
// INSTANCE
// -------------------------------------------- //
private static ARChatColor i = new ARChatColor();
public static ARChatColor get() { return i; }
} }

View File

@ -5,9 +5,20 @@ import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
public class ARDate extends ARAbstractPrimitive<Date> public class ARDate extends ARAbstractPrimitive<Date>
{ {
protected static DateFormat df = new SimpleDateFormat("yyyy-MM-dd"); protected final static DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
private static ARDate i = new ARDate();
public static ARDate get() { return i; }
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override @Override
public String typename() public String typename()
{ {
@ -20,11 +31,4 @@ public class ARDate extends ARAbstractPrimitive<Date>
return df.parse(arg); return df.parse(arg);
} }
// -------------------------------------------- //
// INSTANCE
// -------------------------------------------- //
private static ARDate i = new ARDate();
public static ARDate get() { return i; }
} }

View File

@ -9,6 +9,17 @@ import com.massivecraft.mcore.util.MUtil;
public class ARDifficulty extends ARAbstractSelect<Difficulty> public class ARDifficulty extends ARAbstractSelect<Difficulty>
{ {
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
private static ARDifficulty i = new ARDifficulty();
public static ARDifficulty get() { return i; }
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override @Override
public String typename() public String typename()
{ {
@ -48,11 +59,4 @@ public class ARDifficulty extends ARAbstractSelect<Difficulty>
return MUtil.list("peaceful", "easy", "normal", "hard"); return MUtil.list("peaceful", "easy", "normal", "hard");
} }
// -------------------------------------------- //
// INSTANCE
// -------------------------------------------- //
private static ARDifficulty i = new ARDifficulty();
public static ARDifficulty get() { return i; }
} }

View File

@ -1,7 +1,18 @@
package com.massivecraft.mcore.cmd.arg; package com.massivecraft.mcore.cmd.arg;
public class ARDouble extends ARAbstractPrimitive<Double> public class ARDouble extends ARAbstractPrimitive<Double>
{ {
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
private static ARDouble i = new ARDouble();
public static ARDouble get() { return i; }
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override @Override
public String typename() public String typename()
{ {
@ -14,11 +25,4 @@ public class ARDouble extends ARAbstractPrimitive<Double>
return Double.parseDouble(arg); return Double.parseDouble(arg);
} }
// -------------------------------------------- //
// INSTANCE
// -------------------------------------------- //
private static ARDouble i = new ARDouble();
public static ARDouble get() { return i; }
} }

View File

@ -9,6 +9,17 @@ import com.massivecraft.mcore.util.MUtil;
public class AREnvironment extends ARAbstractSelect<Environment> public class AREnvironment extends ARAbstractSelect<Environment>
{ {
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
private static AREnvironment i = new AREnvironment();
public static AREnvironment get() { return i; }
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override @Override
public String typename() public String typename()
{ {
@ -50,11 +61,4 @@ public class AREnvironment extends ARAbstractSelect<Environment>
return MUtil.list("normal", "end", "nether"); return MUtil.list("normal", "end", "nether");
} }
// -------------------------------------------- //
// INSTANCE
// -------------------------------------------- //
private static AREnvironment i = new AREnvironment();
public static AREnvironment get() { return i; }
} }

View File

@ -1,7 +1,18 @@
package com.massivecraft.mcore.cmd.arg; package com.massivecraft.mcore.cmd.arg;
public class ARFloat extends ARAbstractPrimitive<Float> public class ARFloat extends ARAbstractPrimitive<Float>
{ {
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
private static ARFloat i = new ARFloat();
public static ARFloat get() { return i; }
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override @Override
public String typename() public String typename()
{ {
@ -14,11 +25,4 @@ public class ARFloat extends ARAbstractPrimitive<Float>
return Float.parseFloat(arg); return Float.parseFloat(arg);
} }
// -------------------------------------------- //
// INSTANCE
// -------------------------------------------- //
private static ARFloat i = new ARFloat();
public static ARFloat get() { return i; }
} }

View File

@ -9,6 +9,17 @@ import com.massivecraft.mcore.util.MUtil;
public class ARGameMode extends ARAbstractSelect<GameMode> public class ARGameMode extends ARAbstractSelect<GameMode>
{ {
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
private static ARGameMode i = new ARGameMode();
public static ARGameMode get() { return i; }
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override @Override
public String typename() public String typename()
{ {
@ -44,11 +55,4 @@ public class ARGameMode extends ARAbstractSelect<GameMode>
return MUtil.list("survival", "creative", "adventure"); return MUtil.list("survival", "creative", "adventure");
} }
// -------------------------------------------- //
// INSTANCE
// -------------------------------------------- //
private static ARGameMode i = new ARGameMode();
public static ARGameMode get() { return i; }
} }

View File

@ -2,6 +2,17 @@ package com.massivecraft.mcore.cmd.arg;
public class ARInteger extends ARAbstractPrimitive<Integer> public class ARInteger extends ARAbstractPrimitive<Integer>
{ {
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
private static ARInteger i = new ARInteger();
public static ARInteger get() { return i; }
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override @Override
public String typename() public String typename()
{ {
@ -13,12 +24,5 @@ public class ARInteger extends ARAbstractPrimitive<Integer>
{ {
return Integer.parseInt(arg); return Integer.parseInt(arg);
} }
// -------------------------------------------- //
// INSTANCE
// -------------------------------------------- //
private static ARInteger i = new ARInteger();
public static ARInteger get() { return i; }
} }

View File

@ -1,7 +1,18 @@
package com.massivecraft.mcore.cmd.arg; package com.massivecraft.mcore.cmd.arg;
public class ARLong extends ARAbstractPrimitive<Long> public class ARLong extends ARAbstractPrimitive<Long>
{ {
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
private static ARLong i = new ARLong();
public static ARLong get() { return i; }
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override @Override
public String typename() public String typename()
{ {
@ -14,11 +25,4 @@ public class ARLong extends ARAbstractPrimitive<Long>
return Long.parseLong(arg); return Long.parseLong(arg);
} }
// -------------------------------------------- //
// INSTANCE
// -------------------------------------------- //
private static ARLong i = new ARLong();
public static ARLong get() { return i; }
} }

View File

@ -3,8 +3,19 @@ package com.massivecraft.mcore.cmd.arg;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
public class ARMaterial implements ArgReader<Material> public class ARMaterial extends ArgReaderAbstract<Material>
{ {
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
private static ARMaterial i = new ARMaterial();
public static ARMaterial get() { return i; }
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override @Override
public ArgResult<Material> read(String arg, CommandSender sender) public ArgResult<Material> read(String arg, CommandSender sender)
{ {
@ -17,11 +28,4 @@ public class ARMaterial implements ArgReader<Material>
return result; return result;
} }
// -------------------------------------------- //
// INSTANCE
// -------------------------------------------- //
private static ARMaterial i = new ARMaterial();
public static ARMaterial get() { return i; }
} }

View File

@ -5,8 +5,15 @@ import org.bukkit.command.CommandSender;
import com.massivecraft.mcore.util.TimeDiffUtil; import com.massivecraft.mcore.util.TimeDiffUtil;
import com.massivecraft.mcore.util.Txt; import com.massivecraft.mcore.util.Txt;
public class ARMillisDiff implements ArgReader<Long> public class ARMillisDiff extends ArgReaderAbstract<Long>
{ {
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
private static ARMillisDiff i = new ARMillisDiff();
public static ARMillisDiff get() { return i; }
// -------------------------------------------- // // -------------------------------------------- //
// OVERRIDE // OVERRIDE
// -------------------------------------------- // // -------------------------------------------- //
@ -26,11 +33,4 @@ public class ARMillisDiff implements ArgReader<Long>
return ret; return ret;
} }
// -------------------------------------------- //
// INSTANCE
// -------------------------------------------- //
private static ARMillisDiff i = new ARMillisDiff();
public static ARMillisDiff get() { return i; }
} }

View File

@ -10,6 +10,17 @@ import com.massivecraft.mcore.usys.MultiverseColl;
public class ARMultiverse extends ARAbstractSelect<Multiverse> public class ARMultiverse extends ARAbstractSelect<Multiverse>
{ {
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
private static ARMultiverse i = new ARMultiverse();
public static ARMultiverse get() { return i; }
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override @Override
public String typename() public String typename()
{ {
@ -34,11 +45,4 @@ public class ARMultiverse extends ARAbstractSelect<Multiverse>
return MultiverseColl.i.getIds(); return MultiverseColl.i.getIds();
} }
// -------------------------------------------- //
// INSTANCE
// -------------------------------------------- //
private static ARMultiverse i = new ARMultiverse();
public static ARMultiverse get() { return i; }
} }

View File

@ -7,10 +7,10 @@ import org.bukkit.command.CommandSender;
import com.massivecraft.mcore.mixin.Mixin; import com.massivecraft.mcore.mixin.Mixin;
import com.massivecraft.mcore.util.Txt; import com.massivecraft.mcore.util.Txt;
public abstract class ARSenderIdAbstract<T> implements ArgReader<T> public abstract class ARSenderIdAbstract<T> extends ArgReaderAbstract<T>
{ {
// -------------------------------------------- // // -------------------------------------------- //
// ABSTRACT // CONSTANTS
// -------------------------------------------- // // -------------------------------------------- //
public final static int MAX_COUNT = 10; public final static int MAX_COUNT = 10;

View File

@ -2,6 +2,17 @@ package com.massivecraft.mcore.cmd.arg;
public class ARString extends ARAbstractPrimitive<String> public class ARString extends ARAbstractPrimitive<String>
{ {
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
private static ARString i = new ARString();
public static ARString get() { return i; }
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override @Override
public String typename() public String typename()
{ {
@ -14,11 +25,4 @@ public class ARString extends ARAbstractPrimitive<String>
return arg; return arg;
} }
// -------------------------------------------- //
// INSTANCE
// -------------------------------------------- //
private static ARString i = new ARString();
public static ARString get() { return i; }
} }

View File

@ -8,10 +8,26 @@ import org.bukkit.command.CommandSender;
import com.massivecraft.mcore.usys.Multiverse; import com.massivecraft.mcore.usys.Multiverse;
import com.massivecraft.mcore.util.Txt; import com.massivecraft.mcore.util.Txt;
public class ARUniverse implements ArgReader<String> public class ARUniverse extends ArgReaderAbstract<String>
{ {
// -------------------------------------------- // // -------------------------------------------- //
// IMPLEMENTATION // INSTANCE & CONSTRUCT
// -------------------------------------------- //
public ARUniverse(Multiverse multiverse)
{
this.multiverse = multiverse;
}
// -------------------------------------------- //
// FIELDS
// -------------------------------------------- //
protected Multiverse multiverse;
public Multiverse multiverse() { return this.multiverse; }
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- // // -------------------------------------------- //
@Override @Override
@ -34,19 +50,4 @@ public class ARUniverse implements ArgReader<String>
return result; return result;
} }
// -------------------------------------------- //
// FIELDS
// -------------------------------------------- //
protected Multiverse multiverse;
public Multiverse multiverse() { return this.multiverse; }
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public ARUniverse(Multiverse multiverse)
{
this.multiverse = multiverse;
}
} }

View File

@ -4,8 +4,19 @@ import org.bukkit.Bukkit;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
public class ARWorld implements ArgReader<World> public class ARWorld extends ArgReaderAbstract<World>
{ {
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
private static ARWorld i = new ARWorld();
public static ARWorld get() { return i; }
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override @Override
public ArgResult<World> read(String arg, CommandSender sender) public ArgResult<World> read(String arg, CommandSender sender)
{ {
@ -33,12 +44,4 @@ public class ARWorld implements ArgReader<World>
return ret; return ret;
} }
// -------------------------------------------- //
// INSTANCE
// -------------------------------------------- //
private static ARWorld i = new ARWorld();
public static ARWorld get() { return i; }
} }

View File

@ -9,6 +9,17 @@ import com.massivecraft.mcore.mixin.Mixin;
public class ARWorldId extends ARAbstractSelect<String> public class ARWorldId extends ARAbstractSelect<String>
{ {
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
private static ARWorldId i = new ARWorldId();
public static ARWorldId get() { return i; }
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override @Override
public String typename() public String typename()
{ {
@ -50,11 +61,4 @@ public class ARWorldId extends ARAbstractSelect<String>
return ret; return ret;
} }
// -------------------------------------------- //
// INSTANCE
// -------------------------------------------- //
private static ARWorldId i = new ARWorldId();
public static ARWorldId get() { return i; }
} }

View File

@ -9,6 +9,17 @@ import com.massivecraft.mcore.util.MUtil;
public class ARWorldType extends ARAbstractSelect<WorldType> public class ARWorldType extends ARAbstractSelect<WorldType>
{ {
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
private static ARWorldType i = new ARWorldType();
public static ARWorldType get() { return i; }
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override @Override
public String typename() public String typename()
{ {
@ -60,11 +71,4 @@ public class ARWorldType extends ARAbstractSelect<WorldType>
return MUtil.list("normal", "flat", "1.1", "largebiomes"); return MUtil.list("normal", "flat", "1.1", "largebiomes");
} }
// -------------------------------------------- //
// INSTANCE
// -------------------------------------------- //
private static ARWorldType i = new ARWorldType();
public static ARWorldType get() { return i; }
} }

View File

@ -21,6 +21,10 @@ public class ArgPredictateAnd<T> implements ArgPredictate<T>
this.two = two; this.two = two;
} }
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override @Override
public boolean apply(T type, String arg, CommandSender sender) public boolean apply(T type, String arg, CommandSender sender)
{ {

View File

@ -5,4 +5,7 @@ import org.bukkit.command.CommandSender;
public interface ArgReader<T> public interface ArgReader<T>
{ {
public ArgResult<T> read(String arg, CommandSender sender); public ArgResult<T> read(String arg, CommandSender sender);
public ArgResult<T> read(CommandSender sender);
public ArgResult<T> read(String arg);
public ArgResult<T> read();
} }

View File

@ -0,0 +1,29 @@
package com.massivecraft.mcore.cmd.arg;
import org.bukkit.command.CommandSender;
public abstract class ArgReaderAbstract<T> implements ArgReader<T>
{
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public ArgResult<T> read(CommandSender sender)
{
return this.read(null, sender);
}
@Override
public ArgResult<T> read(String arg)
{
return this.read(arg, null);
}
@Override
public ArgResult<T> read()
{
return this.read(null, null);
}
}

View File

@ -13,10 +13,7 @@ public class ArgResult<T>
protected T result = null; protected T result = null;
public T getResult() { return this.result; } public T getResult() { return this.result; }
public void setResult(T result) { this.result = result; } public void setResult(T result) { this.result = result; }
public boolean hasResult() public boolean hasResult() { return this.getResult() != null; }
{
return this.getResult() != null;
}
// -------------------------------------------- // // -------------------------------------------- //
// FIELD: ERRORS // FIELD: ERRORS

View File

@ -314,6 +314,7 @@ public class MUtil
// SIMPLE CONSTRUCTORS // SIMPLE CONSTRUCTORS
// -------------------------------------------- // // -------------------------------------------- //
@SafeVarargs @SafeVarargs
public static <T> List<T> list(T... items) public static <T> List<T> list(T... items)
{ {

View File

@ -68,6 +68,7 @@ public final class Streams {
TypeAdapters.JSON_ELEMENT.write(writer, element); TypeAdapters.JSON_ELEMENT.write(writer, element);
} }
@SuppressWarnings("resource")
public static Writer writerForAppendable(Appendable appendable) { public static Writer writerForAppendable(Appendable appendable) {
return appendable instanceof Writer ? (Writer) appendable : new AppendableWriter(appendable); return appendable instanceof Writer ? (Writer) appendable : new AppendableWriter(appendable);
} }

View File

@ -52,6 +52,7 @@ public final class ObjectTypeAdapter extends TypeAdapter<Object> {
this.gson = gson; this.gson = gson;
} }
@SuppressWarnings("incomplete-switch")
@Override public Object read(JsonReader in) throws IOException { @Override public Object read(JsonReader in) throws IOException {
JsonToken token = in.peek(); JsonToken token = in.peek();
switch (token) { switch (token) {