Subversion Repository Public Repository

litesoft

Diff Revisions 282 vs 475 for /trunk/Java/GWT/Client/src/com/google/gwt/gen2/table/client/property/ColumnPropertyManager.java

Diff revisions: vs.
  @@ -15,87 +15,92 @@
15 15 */
16 16 package com.google.gwt.gen2.table.client.property;
17 17
18 - import com.google.gwt.gen2.table.client.property.ColumnProperty.Type;
18 + import java.util.*;
19 19
20 - import java.util.HashMap;
21 - import java.util.Map;
20 + import com.google.gwt.gen2.table.client.property.ColumnProperty.*;
22 21
23 22 /**
24 23 * Manager responsible for adding, retrieving, and removing
25 24 * {@link ColumnProperty}.
26 25 */
27 - public class ColumnPropertyManager {
28 - /**
29 - * A map of property types to their associated properties.
30 - */
31 - private Map<Type<?>, ColumnProperty> properties = new HashMap<Type<?>, ColumnProperty>();
32 -
33 - /**
34 - * <p>
35 - * Get the {@link ColumnProperty} associated with the specified
36 - * {@link ColumnProperty.Type}. If the property is not defined, the default
37 - * value will be returned.
38 - * </p>
39 - * <p>
40 - * This method should never return null. Instead, it should return the default
41 - * property from {@link ColumnProperty.Type#getDefault()}.
42 - * </p>
43 - *
44 - * @param <P> the column property type
45 - * @param type the {@link ColumnProperty} type
46 - * @return the property, or the default value if the property is not defined
47 - */
48 - public <P extends ColumnProperty> P getColumnProperty(
49 - ColumnProperty.Type<P> type) {
50 - return getColumnProperty(type, true);
51 - }
52 -
53 - /**
54 - * Get the {@link ColumnProperty} associated with the specified
55 - * {@link ColumnProperty.Type}.
56 - *
57 - * @param <P> the column property type
58 - * @param type the {@link ColumnProperty} type
59 - * @param useDefault if true, return the default property instead of null
60 - * @return the property, or the default value if the property is not defined
61 - */
62 - @SuppressWarnings("unchecked")
63 - public <P extends ColumnProperty> P getColumnProperty(
64 - ColumnProperty.Type<P> type, boolean useDefault) {
65 - Object property = properties.get(type);
66 - if (property == null && useDefault) {
67 - return type.getDefault();
26 + public class ColumnPropertyManager
27 + {
28 + /**
29 + * A map of property types to their associated properties.
30 + */
31 + private Map<Type<?>, ColumnProperty> properties = new HashMap<Type<?>, ColumnProperty>();
32 +
33 + /**
34 + * <p>
35 + * Get the {@link ColumnProperty} associated with the specified
36 + * {@link ColumnProperty.Type}. If the property is not defined, the default
37 + * value will be returned.
38 + * </p>
39 + * <p>
40 + * This method should never return null. Instead, it should return the default
41 + * property from {@link ColumnProperty.Type#getDefault()}.
42 + * </p>
43 + *
44 + * @param <P> the column property type
45 + * @param type the {@link ColumnProperty} type
46 + *
47 + * @return the property, or the default value if the property is not defined
48 + */
49 + public <P extends ColumnProperty> P getColumnProperty( ColumnProperty.Type<P> type )
50 + {
51 + return getColumnProperty( type, true );
68 52 }
69 - return (P) property;
70 - }
71 53
72 - /**
73 - * Remove an existing {@link ColumnProperty} if it has already been added.
74 - *
75 - * @param type the type of the property to remove
76 - * @return the removed property, or null if one was never set
77 - */
78 - @SuppressWarnings("unchecked")
79 - public <P extends ColumnProperty> P removeColumnProperty(
80 - ColumnProperty.Type<P> type) {
81 - Object property = properties.remove(type);
82 - if (property == null) {
83 - return null;
54 + /**
55 + * Get the {@link ColumnProperty} associated with the specified
56 + * {@link ColumnProperty.Type}.
57 + *
58 + * @param <P> the column property type
59 + * @param type the {@link ColumnProperty} type
60 + * @param useDefault if true, return the default property instead of null
61 + *
62 + * @return the property, or the default value if the property is not defined
63 + */
64 + @SuppressWarnings("unchecked")
65 + public <P extends ColumnProperty> P getColumnProperty( ColumnProperty.Type<P> type, boolean useDefault )
66 + {
67 + Object property = properties.get( type );
68 + if ( property == null && useDefault )
69 + {
70 + return type.getDefault();
71 + }
72 + return (P) property;
84 73 }
85 - return (P) property;
86 - }
87 74
88 - /**
89 - * Set a {@link ColumnProperty}.
90 - *
91 - * @param <P> the column property type
92 - * @param type the {@link ColumnProperty} type
93 - * @param property the property to set
94 - */
95 - public <P extends ColumnProperty> void setColumnProperty(
96 - ColumnProperty.Type<P> type, P property) {
97 - assert type != null : "Cannot add a property with a null type";
98 - assert property != null : "Cannot add a null property";
99 - properties.put(type, property);
100 - }
75 + /**
76 + * Remove an existing {@link ColumnProperty} if it has already been added.
77 + *
78 + * @param type the type of the property to remove
79 + *
80 + * @return the removed property, or null if one was never set
81 + */
82 + @SuppressWarnings("unchecked")
83 + public <P extends ColumnProperty> P removeColumnProperty( ColumnProperty.Type<P> type )
84 + {
85 + Object property = properties.remove( type );
86 + if ( property == null )
87 + {
88 + return null;
89 + }
90 + return (P) property;
91 + }
92 +
93 + /**
94 + * Set a {@link ColumnProperty}.
95 + *
96 + * @param <P> the column property type
97 + * @param type the {@link ColumnProperty} type
98 + * @param property the property to set
99 + */
100 + public <P extends ColumnProperty> void setColumnProperty( ColumnProperty.Type<P> type, P property )
101 + {
102 + assert type != null : "Cannot add a property with a null type";
103 + assert property != null : "Cannot add a null property";
104 + properties.put( type, property );
105 + }
101 106 }