EMMA Coverage Report (generated Tue Apr 17 08:51:20 BST 2007)
[all classes][org.jtoolkit.essence.app.pojo]

COVERAGE SUMMARY FOR SOURCE FILE [DataValue.java]

nameclass, %method, %block, %line, %
DataValue.java100% (1/1)40%  (4/10)33%  (23/70)37%  (7/19)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class DataValue100% (1/1)40%  (4/10)33%  (23/70)37%  (7/19)
asMap (): Map 0%   (0/1)0%   (0/3)0%   (0/1)
getName (): String 0%   (0/1)0%   (0/9)0%   (0/3)
getNames (): Set 0%   (0/1)0%   (0/4)0%   (0/1)
getValue (String): Object 0%   (0/1)0%   (0/18)0%   (0/5)
project (Class, Object []): DataValue 0%   (0/1)0%   (0/6)0%   (0/1)
setCopy (String, Object, Object []): DataValue 0%   (0/1)0%   (0/7)0%   (0/1)
DataValue (): void 100% (1/1)100% (6/6)100% (3/3)
equals (Object): boolean 100% (1/1)100% (4/4)100% (1/1)
hashCode (): int 100% (1/1)100% (10/10)100% (2/2)
toString (): String 100% (1/1)100% (3/3)100% (1/1)

1package org.jtoolkit.essence.app.pojo;
2 
3import org.jetbrains.annotations.NotNull;
4import org.jtoolkit.essence.app.pojo.impl.DataValueClass;
5import org.jtoolkit.essence.concurrency.Immutable;
6import org.jtoolkit.essence.utils.Named;
7 
8import java.util.Map;
9import java.util.NoSuchElementException;
10import java.util.Set;
11import java.lang.reflect.InvocationTargetException;
12 
13/*
14   Copyright 2006 Peter Lawrey
15 
16   Licensed under the Apache License, Version 2.0 (the "License");
17   you may not use this file except in compliance with the License.
18   You may obtain a copy of the License at
19 
20       http://www.apache.org/licenses/LICENSE-2.0
21 
22   Unless required by applicable law or agreed to in writing, software
23   distributed under the License is distributed on an "AS IS" BASIS,
24   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
25   See the License for the specific language governing permissions and
26   limitations under the License.
27*/
28 
29/**
30 * Root object class for immutable data value classes.
31 * <p/>A data value class is any immutable class which can be represented as a series of key value pairs
32 * and has a constructor which initialises all field in the order they are defined.  A data value object
33 * does not need to extend this class instead this class defines a number of useful methods.
34 * <p/>Note: data value class can have public fields but they should be final.
35 *
36 * @author Peter Lawrey
37 */
38@Immutable
39public class DataValue<T extends DataValue> implements Named.Source<Object> {
40    @SuppressWarnings("DollarSignInName")
41    private transient int $hashCode = 0;
42 
43    /**
44     * Cannot create a plan data value object with no values.
45     */
46    protected DataValue() {
47    }
48 
49    public boolean equals(Object obj) {
50        return DataValueClass.equals(this, obj);
51    }
52 
53    @SuppressWarnings("NonFinalFieldReferencedInHashCode")
54    public int hashCode() {
55        if ($hashCode == 0) $hashCode = DataValueClass.hashCode(this);
56        return $hashCode;
57    }
58 
59    public String toString() {
60        return DataValueClass.toString(this);
61    }
62 
63    @NotNull public Map<String, Object> asMap() {
64        return DataValueClass.asMap(this);
65    }
66 
67    @SuppressWarnings({"UnusedDeclaration"})
68    public T setCopy(@NotNull String field, Object value, Object... others) {
69        //noinspection unchecked
70        return (T) DataValueClass.setNew(this, field, value, others);
71    }
72 
73    @SuppressWarnings({"UnusedDeclaration"})
74    public <T2 extends DataValue> T2 project(@NotNull Class<T2> class2, Object... keyValues) {
75        return DataValueClass.project(class2, this, keyValues);
76    }
77 
78    @NotNull public Set<String> getNames() {
79        return DataValueClass.getFieldNames(getClass());
80    }
81 
82    public Object getValue(@NotNull String name) throws NoSuchElementException {
83        try {
84            return DataValueClass.getField(this, name);
85        } catch (IllegalAccessException e) {
86            throw new NoSuchElementException(e.toString());
87        } catch (InvocationTargetException e) {
88            throw new NoSuchElementException(e.toString());
89        }
90    }
91 
92    @NotNull public String getName() {
93        try {
94            return (String) getValue("name");
95        } catch (NoSuchElementException ignored) {
96            return toString();
97        }
98    }
99}

[all classes][org.jtoolkit.essence.app.pojo]
EMMA 2.0.5312 (C) Vladimir Roubtsov