fr.ird.observe.binder.EntityReferenceBinderSupport Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of common-db Show documentation
Show all versions of common-db Show documentation
ObServe Toolkit Common Db module
The newest version!
package fr.ird.observe.binder;
/*-
* #%L
* ObServe Toolkit :: Common Db
* %%
* Copyright (C) 2008 - 2017 IRD, Ultreia.io
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program. If not, see
* .
* #L%
*/
import fr.ird.observe.dto.IdDto;
import fr.ird.observe.dto.constants.ReferentialLocale;
import fr.ird.observe.dto.reference.DtoReference;
import fr.ird.observe.entities.ObserveEntity;
/**
* Created by tchemit on 28/08/17.
*
* @author Tony Chemit - [email protected]
*/
public abstract class EntityReferenceBinderSupport, E extends ObserveEntity> extends EntityBinderSupport {
private final Class referenceType;
public EntityReferenceBinderSupport(Class dtoType, Class referenceType, Class entityType) {
super(dtoType, entityType);
this.referenceType = referenceType;
}
public Class getReferenceType() {
return referenceType;
}
public abstract R toReference(ReferentialLocale referentialLocale, E entity);
public E toEntity(R reference) {
E entity = newEntity();
entity.setTopiaId(reference.getId());
//FIXME Should we do more here? if not rename the method
return entity;
}
}