/*
- * Sone - SimpleFieldSetBuilder.java - Copyright © 2011 David Roden
+ * Sone - SimpleFieldSetBuilder.java - Copyright © 2011–2013 David Roden
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
package net.pterodactylus.sone.freenet;
-import net.pterodactylus.util.validation.Validation;
+import static com.google.common.base.Preconditions.checkNotNull;
+
import freenet.support.SimpleFieldSet;
/**
* The simple field set to build
*/
public SimpleFieldSetBuilder(SimpleFieldSet simpleFieldSet) {
- Validation.begin().isNotNull("Simple Field Set", simpleFieldSet).check();
- this.simpleFieldSet = simpleFieldSet;
+ this.simpleFieldSet = checkNotNull(simpleFieldSet, "simpleFieldSet must not be null");
}
/**
}
/**
+ * Copies the given simple field set into the simple field set being built
+ * in this builder, overwriting all previously existing values.
+ *
+ * @param simpleFieldSet
+ * The simple field set to copy
+ * @return This simple field set builder
+ */
+ public SimpleFieldSetBuilder put(SimpleFieldSet simpleFieldSet) {
+ this.simpleFieldSet.putAllOverwrite(simpleFieldSet);
+ return this;
+ }
+
+ /**
* Stores the given value under the given key, overwriting any previous
* value.
*
return this;
}
+ /**
+ * Stores the given value under the given key, overwriting any previous
+ * value.
+ *
+ * @param key
+ * The key of the value
+ * @param value
+ * The value to store
+ * @return This simple field set builder
+ */
+ public SimpleFieldSetBuilder put(String key, long value) {
+ simpleFieldSet.put(key, value);
+ return this;
+ }
+
}