All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.appdapter.gui.util.ObjectFinder Maven / Gradle / Ivy

Go to download

Appdapter Maven project including Java and Scala, produces jar, not bundle. Excludes concrete SLF4J binding.

The newest version!
package org.appdapter.gui.util;

import java.util.Map;

public interface ObjectFinder {

	static public interface GetF {
		O getValue();
	}

	static public class GetFoundImpl implements GetF {
		final O found;

		public GetFoundImpl(O obj) {
			found = obj;
		}

		@Override public O getValue() {
			return found;
		}

	}

	static public interface SetFound {

		public void setValue(O val);

		static public class SetFoundImpl implements SetFound {
			final O found;
			private K key;
			private Map backing;

			public SetFoundImpl(Map map, K key, O obj) {
				found = obj;
			}

			@Override public void setValue(O val) {
				backing.put(key, val);
			}
		}
	}

	static public interface Found extends Map.Entry {
	}

	static public class FoundObject implements Found {

		String key;
		private final GetF getFound;
		private final Map backing;

		public FoundObject(Map map, String name, GetF getf) {
			this.key = name;
			this.getFound = getf;
			this.backing = map;
		}

		public FoundObject(String name, O o) {
			this(null, name, new GetFoundImpl(o));
		}

		@Override public String getKey() {
			return key;
		}

		@Override public O getValue() {
			if (getFound == null)
				return backing.get(key);
			return getFound.getValue();
		}

		@Override public O setValue(O value) {
			return backing.put(key, value);
		}

	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy