View Javadoc

1   package org.starobjects.wicket.model.util;
2   
3   
4   import org.nakedobjects.metamodel.adapter.NakedObject;
5   import org.nakedobjects.metamodel.adapter.oid.Oid;
6   import org.nakedobjects.runtime.context.NakedObjectsContext;
7   import org.nakedobjects.runtime.persistence.adaptermanager.AdapterManager;
8   
9   import com.google.common.base.Function;
10  
11  public final class Pojos {
12  
13  	private Pojos(){}
14  
15  	public static Function<Object, Oid> toOid() {
16  		return new Function<Object, Oid>() {
17  			public Oid apply(Object pojo) {
18  				NakedObject adapter = getAdapterManager().adapterFor(pojo);
19  				return adapter.getOid();
20  			}
21  
22  		};
23  	}
24  	
25  	public static Function<NakedObject, Object> forAdapter() {
26  		return new Function<NakedObject, Object>() {
27  			
28  			public Object apply(NakedObject from) {
29  				return from.getObject();
30  			}
31  		};
32  	}
33  
34  	private static AdapterManager getAdapterManager() {
35  		return NakedObjectsContext.getPersistenceSession().getAdapterManager();
36  	}
37  
38  
39  }