From c44520f25b0064b9ca6a00b2450445954e8d577e Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Fri, 8 Apr 2011 15:36:11 +0200 Subject: [PATCH] Add method to return an int with a default value. --- .../pterodactylus/sone/freenet/fcp/AbstractCommand.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/main/java/net/pterodactylus/sone/freenet/fcp/AbstractCommand.java b/src/main/java/net/pterodactylus/sone/freenet/fcp/AbstractCommand.java index 3475910..6018c38 100644 --- a/src/main/java/net/pterodactylus/sone/freenet/fcp/AbstractCommand.java +++ b/src/main/java/net/pterodactylus/sone/freenet/fcp/AbstractCommand.java @@ -72,4 +72,20 @@ public abstract class AbstractCommand implements Command { } } + /** + * Returns an int value from the given simple field set, returning a default + * value if the value can not be found or converted. + * + * @param simpleFieldSet + * The simple field set to get the value from + * @param key + * The key of the value + * @param defaultValue + * The default value + * @return The int value + */ + protected int getInt(SimpleFieldSet simpleFieldSet, String key, int defaultValue) { + return simpleFieldSet.getInt(key, defaultValue); + } + } -- 2.7.4