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

net.sixpointsix.springboot.datafixture.DataFixture Maven / Gradle / Ivy

There is a newer version: 1.2.0
Show newest version
package net.sixpointsix.springboot.datafixture;

/**
 * Basic data initializer that can be used to persist a custom set of data.
 *
 * Example usage:
 *
 * 

 * public class MyInitializer implements DataFixture {
 *
 *      @Autowired
 *      private UserRepository userRepository;
 *
 *      public boolean shouldRun() { userRepository.findUserByName("Bob") == null; }
 *
 *     public void run() {
 *          userRepository.save(new User("Bob"));
 *     }
 * }
 * 
*/ public interface DataFixture { int DEFAULT_ORDER = 1000; /** * Test if this initializer should be run * @return true if this should be executed */ boolean shouldRun(); /** * Run the data initialization */ void run(); /** * Get the order of the data initializer, to be sorted lowest to highest * @return Order */ default int getOrder() { return DEFAULT_ORDER; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy