Example usage for java.lang Module.ModuleComparator Module.ModuleComparator

List of usage examples for java.lang Module.ModuleComparator Module.ModuleComparator

Introduction

In this page you can find the example usage for java.lang Module.ModuleComparator Module.ModuleComparator.

Prototype

Module.ModuleComparator

Source Link

Usage

From source file:org.openwms.core.module.ModuleServiceImpl.java

/**
 * {@inheritDoc}/*w ww . j a  va2  s.c o  m*/
 * <p>
 * Additionally the {@code startupOrder} is re-calculated for the new {@link Module}.
 *
 * @throws org.ameba.exception.ServiceLayerException when {@code module} is {@literal null}
 */
@Override
public Module save(Module module) {
    Assert.notNull(module, ExceptionCodes.MODULE_SAVE_NOT_BE_NULL);
    if (module.isNew()) {
        List<Module> all = findAll();
        if (!all.isEmpty()) {
            Collections.sort(all, new Module.ModuleComparator());
            module.setStartupOrder(all.get(all.size() - 1).getStartupOrder() + 1);
        }
    }
    return moduleDao.save(module);
}