import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.text.MessageFormat;
-import java.util.ArrayList;
import java.util.Arrays;
+import java.util.HashMap;
import java.util.Iterator;
-import java.util.List;
+import java.util.Map;
import java.util.Properties;
import java.util.ResourceBundle;
import java.util.StringTokenizer;
* @param className Class name to iterate over
* @return An iterator over all object's fields
*/
- protected Iterator<Object> fieldIterator (final FrameworkInterface instance, final String className) {
+ protected Iterator<Map.Entry<Field, Object>> fieldIterator (final FrameworkInterface instance, final String className) {
// Trace message
this.getLogger().trace(MessageFormat.format("instance={0},className={1} - CALLED!", instance, className));
// Debug message
this.getLogger().debug(MessageFormat.format("Found {0} fields.", fields.length));
- // A list is fine
- List<Object> list = new ArrayList<>(fields.length);
+ // A simple map with K=fieldName and V=Value is fine
+ Map<Field, Object> map = new HashMap<>(fields.length);
// Walk through all
for (final Field field : fields) {
this.getLogger().debug(MessageFormat.format("value={0}", value));
// Add it to list
- boolean added = list.add(value);
-
- // Debug log
- this.getLogger().debug("added=" + added);
+ map.put(field, value);
}
// Debug message
- this.getLogger().debug(MessageFormat.format("Returning iterator for {0} entries ...", list.size()));
+ this.getLogger().debug(MessageFormat.format("Returning iterator for {0} entries ...", map.size()));
// Return list iterator
- return list.iterator();
+ return map.entrySet().iterator();
}
}
*/
package org.mxchange.jcore.contact;
+import java.lang.reflect.Field;
import java.text.MessageFormat;
import java.util.Iterator;
+import java.util.Map;
import java.util.Objects;
import org.mxchange.jcore.BaseFrameworkSystem;
import org.mxchange.jcore.client.Client;
* @return An iterator
*/
@Override
- public Iterator<Object> iterator () {
+ public Iterator<Map.Entry<Field, Object>> iterator () {
return this.fieldIterator(this, "BaseContact");
}
*/
package org.mxchange.jcore.contact;
+import java.lang.reflect.Field;
+import java.util.Iterator;
+import java.util.Map;
import org.mxchange.jcore.FrameworkInterface;
import org.mxchange.jcore.client.Client;
*
* @author Roland Haeder
*/
-public interface Contact extends FrameworkInterface, Iterable<Object> {
+public interface Contact extends FrameworkInterface {
+ /**
+ * Returns an iterator of all values from this object
+ * @return An iterator
+ */
+ public Iterator<Map.Entry<Field, Object>> iterator ();
/**
* Some "getter" for translated gender of the contact