All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.nuiton.topia.persistence.TopiaIdFactory Maven / Gradle / Ivy

The newest version!
package org.nuiton.topia.persistence;

/*
 * #%L
 * ToPIA Extension :: API
 * %%
 * Copyright (C) 2018 - 2022 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 java.io.Serializable;

/**
 * This contract represents a topiaId generation strategy.
 *
 * It can be used in both ways :
 * 
    *
  • generate a new topiaId from a given class;
  • *
  • retrieves a class or random part from a given topiaId.
  • *
* * You can change the implementation used by ToPIA by changing configuration. * * {@link java.io.Serializable} must be implemented because * {@link org.nuiton.topia.persistence.TopiaConfiguration} may hold some references. * * @author Brendan Le Ny - [email protected] * @author Tony Chemit - [email protected] * @see org.nuiton.topia.persistence.TopiaConfiguration#getTopiaIdFactory() * @since 3.0 */ public interface TopiaIdFactory extends Serializable { /** * Generates a new topiaId for the given entity type and the given entity. * * @param entityClass type of entity (must be a not null interface) * @param topiaEntity the entity on which we want to generate the id (must be not null) * @param type of entity * @return the new topiaId for the given entity */ String newTopiaId(Class entityClass, TopiaEntity topiaEntity); /** * Builds a new topiaId for the given entity type and the given random part. * * @param entityClass type of entity (must be a not null interface) * @param randomPart the random part of the topiaId * @param type of entity * @return the new topiaId */ String newTopiaId(Class entityClass, String randomPart); /** * @param topiaId the topiaId to inspect * @param type of the entity * @return the FQN part of the topiaId */ Class getClassName(String topiaId); /** * @param topiaId the topiaId to inspect * @return the random part of the topiaId */ String getRandomPart(String topiaId); /** * @return the separator between the FQN and the random part of any topiaId. */ String getSeparator(); /** * @param str FIXME * @return true if given argument is a well formatted topiaId */ boolean isTopiaId(String str); }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy