Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright 2014 Tomas Rodriguez Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
 package com.github.talberto.easybeans.atg;
 import static;

Tomas Rodriguez (
 public class RepositoryPropertyMapper {
   protected static Logger sLog = LoggerFactory.getLogger(RepositoryBeanMapper.class);
   protected Logger mLog = LoggerFactory.getLogger(this.getClass());
   protected Method mReader;
   protected Method mWriter;
   protected PropertyDescriptor mProperty;
   public static RepositoryPropertyMapper from(PropertyDescriptor pProperty) {
     return new RepositoryPropertyMapper(pProperty);
   protected RepositoryPropertyMapper(PropertyDescriptor pProperty) {
      = pProperty;
     .debug("Extracting information from property [{}]".getName());
      = pProperty.getReadMethod();
     checkArgument( != null ||  != null"Neither reader nor writer for property [{}]".getName());
     RepositoryProperty readerAnnotation =  != null ? .getAnnotation(RepositoryProperty.class) : null;
     RepositoryProperty writerAnnotation =  != null ? .getAnnotation(RepositoryProperty.class) : null;
     checkArgument(readerAnnotation != null || writerAnnotation != null"Neither reader nor writer are annotated with @RepositoryProperty for property {}".getName());
     checkArgument(!(readerAnnotation != null && writerAnnotation != null), "Both reader and writer are annotated with @RepositoryProperty for property {}".getName());
     boolean configureWithReader = readerAnnotation == null ? false : true;
     RepositoryProperty propertyAnnotation = configureWithReader ? readerAnnotation : writerAnnotation;
     if(configureWithReader) {
       .debug("Configuring property using reader method");
     } else {
       .debug("Configuring property using writer method");
     propertyAnnotation = .getAnnotation(RepositoryProperty.class);
     if(propertyAnnotation != null) {
        = propertyAnnotation.propertyName(); // Name of the property in the Repository
       .debug("Property configured: [propertyName=[{}]]");


the repositoryPropertyName
     return ;
   public String getBeanPropertyName() {
     return .getName();
   public void setBeanProperty(Object pBeanObject pPropertyValue) {
     try {
     } catch (Exception e) {
       // TODO Auto-generated catch block
   public Object getBeanProperty(Object pBeanString pPropertyName) {
     try {
      return .invoke(pBean);
    } catch(Exception e) {
      throw new MappingException(e);
  public Class<?> getPropertyBeanType() {
    return .getPropertyType();
New to GrepCode? Check out our FAQ X