Add API for representing configuration of resources
[smart-dao.git] / smart-rs / src / main / java / com / smartitengineering / exim / AssociationConfig.java
blob4f117d3379ad3b92191d512572dc4514be79afaa
1 /*
2 * This is a common dao with basic CRUD operations and is not limited to any
3 * persistent layer implementation
4 *
5 * Copyright (C) 2008 Imran M Yousuf (imyousuf@smartitengineering.com)
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 3 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 package com.smartitengineering.exim;
21 import java.util.Collection;
22 import java.util.List;
23 import java.util.Map;
24 import java.util.Set;
26 /**
27 * A configuration API for all association in an exim-able object. Since in Java
28 * all types are of type {@link Object} we will considering every member (a
29 * field or a property) an association and thus store a configuration for it.
30 * @author imyousuf
31 * @since 0.4
33 public interface AssociationConfig {
35 /**
36 * Defines whether the associate is to be exported as URI or not.
37 * @return True if its expected to export as URI else false
39 public boolean isItToBeExportedAsUri();
41 /**
42 * Defines whether the association is to be ignored for when the domain is
43 * exported or imported.
44 * @return True if it is to be ignored for Ex-Im.
46 public boolean isTransient();
48 /**
49 * Defines whether the object should be imported eagerly or on demand. It
50 * will only be supported if the resource is exported using properties. If
51 * any association config has it set then it will use CGLIB for proxying the
52 * resources.
53 * @return True if association is to be fetched eagerly.
54 * @see AssociationConfig#isItToBeExportedAsUri()
55 * @see AssociationConfig#isTransient()
57 public boolean isEagerSet();
59 /**
60 * Defines the name representing the association in the exported doc.
61 * @return Name to be used in export/import; if null then field/property
62 * name will be used instead.
64 public String getName();
66 /**
67 * Defines whether the association has its own string value generator
68 * implementation, (if its not exported as URI) if it does have a provider
69 * then it will be used else toString will be used.
70 * @return True if it has a string provider implemented.
71 * @see AssociationConfig#isItToBeExportedAsUri()
73 public boolean isStringProviderImplemented();
75 /**
76 * Defines the type of association this configuration represents
77 * @return Type of the associaiton
79 public AssociationType getAssociationType();
81 /**
82 * It defimes types that impacts how the data is used in order to be
83 * exported.
85 public enum AssociationType {
87 TYPE_OBJECT(Object.class),
88 TYPE_LIST(List.class),
89 TYPE_SET(Set.class),
90 TYPE_COLLECTION(Collection.class),
91 TYPE_ARRAY(Object.class),
92 TYPE_MAP(Map.class),;
93 private Class rootClass;
95 AssociationType(Class rootClass) {
96 this.rootClass = rootClass;
99 public Class getRootClass() {
100 return rootClass;