Package com.asakusafw.testdriver.core

Examples of com.asakusafw.testdriver.core.PropertyName


        Map<PropertyName, Method> results = new TreeMap<PropertyName, Method>();
        for (Method method : modelClass.getMethods()) {
            if (VALUE_DRIVERS.containsKey(method.getReturnType()) == false) {
                continue;
            }
            PropertyName property = getPropertyNameIfAccessor(method);
            if (property == null) {
                continue;
            }
            results.put(property, method);
        }

        PropertyOrder annotation = modelClass.getAnnotation(PropertyOrder.class);
        if (annotation == null) {
            LOG.info("Annotation {} is not defined in {}",
                    PropertyOrder.class.getSimpleName(),
                    modelClass.getName());
            return results;
        }
        Map<PropertyName, Method> ordered = new LinkedHashMap<PropertyName, Method>();
        for (String name : annotation.value()) {
            String[] words = name.split("(_|-)+");
            PropertyName propertyName = PropertyName.newInstance(words);
            Method method = results.remove(propertyName);
            if (method == null) {
                LOG.warn("Property {} is not found in {}", name, modelClass.getName());
            } else {
                ordered.put(propertyName, method);
View Full Code Here


    @Override
    public DataModelReflection toReflection(T object) {
        Builder<T> builder = newReflection();
        try {
            for (Map.Entry<PropertyName, Method> entry : accessors.entrySet()) {
                PropertyName property = entry.getKey();
                Method accessor = entry.getValue();
                Object value = get(object, accessor);
                builder.add(property, value);
            }
        } catch (Exception e) {
View Full Code Here

    @Override
    public T toObject(DataModelReflection reflection) {
        try {
            T instance = modelClass.newInstance();
            for (Map.Entry<PropertyName, Method> entry : accessors.entrySet()) {
                PropertyName property = entry.getKey();
                Method accessor = entry.getValue();
                Object value = reflection.getValue(property);
                set(instance, accessor, value);
            }
            return instance;
View Full Code Here

    }

    private Map<PropertyName, Field> collectProperties() {
        Map<PropertyName, Field> results = new HashMap<PropertyName, Field>();
        for (Field field : modelClass.getDeclaredFields()) {
            PropertyName name = extract(field);
            if (name != null) {
                results.put(name, field);
            }
        }
        return Collections.unmodifiableMap(results);
View Full Code Here

    @Override
    public DataModelReflection toReflection(T object) {
        Builder<T> builder = newReflection();
        for (Map.Entry<PropertyName, Field> entry : fields.entrySet()) {
            PropertyName name = entry.getKey();
            Field field = entry.getValue();
            try {
                Object value = field.get(object);
                builder.add(name, value);
            } catch (IllegalAccessException e) {
View Full Code Here

    @Override
    public T toObject(DataModelReflection reflection) {
        try {
            T instance = modelClass.newInstance();
            for (Map.Entry<PropertyName, Field> entry : fields.entrySet()) {
                PropertyName name = entry.getKey();
                Field field = entry.getValue();
                Object value = reflection.getValue(name);
                try {
                    field.set(instance, value);
                } catch (IllegalAccessException e) {
View Full Code Here

    public Property property(String name) {
        if (name == null) {
            throw new IllegalArgumentException("name must not be null"); //$NON-NLS-1$
        }
        String[] words = name.split("_|-|\\s+");
        PropertyName propertyName = PropertyName.newInstance(words);
        PropertyType type = definition.getType(propertyName);
        if (type == null) {
            throw new IllegalArgumentException(MessageFormat.format(
                    "\"{0}\"にプロパティ\"{1}\"は定義されていません",
                    definition.getModelClass().getName(),
View Full Code Here

        assert definition != null;
        assert columnNames != null;
        Map<String, PropertyName> allMapping = extractAllMappings();
        Map<String, PropertyName> results = new LinkedHashMap<String, PropertyName>();
        for (String column : columnNames) {
            PropertyName propertyName = allMapping.get(column);
            if (propertyName == null) {
                LOG.warn(MessageFormat.format(
                        "カラム{0}.{1}に対応するプロパティが{2}に見つかりませんでした。このカラムをスキップします",
                        tableName,
                        column,
View Full Code Here

                        "最初の行はプロパティ名を文字列で指定してください: (id={0}, column={1})",
                        id,
                        cell.getColumnIndex() + 1));
            }
            String name = cell.getStringCellValue();
            PropertyName property = toPropertyName(cell, name);
            if (definition.getType(property) == null) {
                throw new IOException(MessageFormat.format(
                        "{0}にプロパティ\"{1}\"は定義されていません: (id={2}, column={3})",
                        definition.getModelClass().getName(),
                        property,
View Full Code Here

    private Matcher<PropertyName> name(final String words) {
        return new BaseMatcher<PropertyName>() {
            @Override
            public boolean matches(Object o) {
                if (o instanceof PropertyName) {
                    PropertyName other = (PropertyName) o;
                    PropertyName name = PropertyName.newInstance(words.split("_"));
                    return other.equals(name);
                }
                return false;
            }
View Full Code Here

TOP

Related Classes of com.asakusafw.testdriver.core.PropertyName

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.