Skip to content

Commit

Permalink
Fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Emil Forslund committed May 8, 2016
1 parent 04f1298 commit ac793d3
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 79 deletions.
Expand Up @@ -3,17 +3,40 @@
import com.speedment.runtime.annotation.Api; import com.speedment.runtime.annotation.Api;


/** /**
* * Contains general information about the installment like the software title
* and version. This is used to print correct messages for an example when the
* application launches.
*
* @author Emil Forslund * @author Emil Forslund
* @since 2.4.0 * @since 2.4.0
*/ */
@Api(version = "2.4") @Api(version = "2.4")
public interface InfoComponent extends Component { public interface InfoComponent extends Component {


/**
* The title of Speedment.
*
* @return the title
*/
String title(); String title();

/**
* The subtitle of Speedment.
*
* @return the subtitle
*/
String subtitle(); String subtitle();

/**
* The version of Speedment.
*
* @return the version
*/
String version(); String version();


/**
* {@inheritDoc}
*/
@Override @Override
public default Class<InfoComponent> getComponentClass() { public default Class<InfoComponent> getComponentClass() {
return InfoComponent.class; return InfoComponent.class;
Expand Down
Expand Up @@ -32,8 +32,6 @@
*/ */
public interface Lifecyclable<T extends Lifecyclable<T>> { public interface Lifecyclable<T extends Lifecyclable<T>> {


final Logger LIFECYCLABLE_LOGGER = LoggerManager.getLogger(Lifecyclable.class);

/** /**
* Sets the {@link State} of this {@code Lifecyclable} directly. This should * Sets the {@link State} of this {@code Lifecyclable} directly. This should
* only be called internally. * only be called internally.
Expand Down Expand Up @@ -80,16 +78,7 @@ default void onInitialize() {
* @see #preInitialize() * @see #preInitialize()
* @see #onInitialize() * @see #onInitialize()
*/ */
default T initialize() { T initialize();
LIFECYCLABLE_LOGGER.debug("Initializing " + getClass().getSimpleName());
getState().checkNextState(State.INIITIALIZED);
preInitialize();
onInitialize();
setState(State.INIITIALIZED);
@SuppressWarnings("unchecked")
final T self = (T) this;
return self;
}


/** /**
* Overridable method that can add logic before the load phase. * Overridable method that can add logic before the load phase.
Expand Down Expand Up @@ -122,19 +111,7 @@ default void onLoad() {
* @see #preLoad() * @see #preLoad()
* @see #onLoad() * @see #onLoad()
*/ */
default T load() { T load();
if (getState() == State.CREATED) {
initialize();
}
LIFECYCLABLE_LOGGER.debug("Loading " + getClass().getSimpleName());
getState().checkNextState(State.LOADED);
preLoad();
onLoad();
setState(State.LOADED);
@SuppressWarnings("unchecked")
final T self = (T) this;
return self;
}


/** /**
* Overridable method that can add logic before the resolve phase. * Overridable method that can add logic before the resolve phase.
Expand Down Expand Up @@ -167,22 +144,7 @@ default void onResolve() {
* @see #preResolve() * @see #preResolve()
* @see #onResolve() * @see #onResolve()
*/ */
default T resolve() { T resolve();
if (getState() == State.CREATED) {
initialize();
}
if (getState() == State.INIITIALIZED) {
load();
}
LIFECYCLABLE_LOGGER.debug("Resolving " + getClass().getSimpleName());
getState().checkNextState(State.RESOLVED);
preResolve();
onResolve();
setState(State.RESOLVED);
@SuppressWarnings("unchecked")
final T self = (T) this;
return self;
}


/** /**
* Overridable method that can add logic before the start phase. * Overridable method that can add logic before the start phase.
Expand Down Expand Up @@ -216,25 +178,7 @@ default void onStart() {
* @see #preStart() * @see #preStart()
* @see #onStart() * @see #onStart()
*/ */
default T start() { T start();
if (getState() == State.CREATED) {
initialize();
}
if (getState() == State.INIITIALIZED) {
load();
}
if (getState() == State.LOADED) {
resolve();
}
LIFECYCLABLE_LOGGER.debug("Starting " + getClass().getSimpleName());
getState().checkNextState(State.STARTED);
preStart();
onStart();
setState(State.STARTED);
@SuppressWarnings("unchecked")
final T self = (T) this;
return self;
}


/** /**
* Overridable method that can add logic before the stopping phase. * Overridable method that can add logic before the stopping phase.
Expand Down Expand Up @@ -280,17 +224,7 @@ default void postStop() {
* @see #onStop() * @see #onStop()
* @see #postStop() * @see #postStop()
*/ */
default T stop() { T stop();
LIFECYCLABLE_LOGGER.debug("Stopping " + getClass().getSimpleName());
getState().checkNextState(State.STOPPED);
preStop();
onStop();
postStop();
setState(State.STOPPED);
@SuppressWarnings("unchecked")
final T self = (T) this;
return self;
}


/** /**
* Returns {@code true} if this {@code Lifecyclable} is in the * Returns {@code true} if this {@code Lifecyclable} is in the
Expand Down
Expand Up @@ -17,6 +17,8 @@
package com.speedment.runtime.internal.core.runtime; package com.speedment.runtime.internal.core.runtime;


import com.speedment.runtime.component.Lifecyclable; import com.speedment.runtime.component.Lifecyclable;
import com.speedment.runtime.internal.logging.Logger;
import com.speedment.runtime.internal.logging.LoggerManager;
import static java.util.Objects.requireNonNull; import static java.util.Objects.requireNonNull;


/** /**
Expand Down Expand Up @@ -52,6 +54,7 @@
*/ */
public abstract class AbstractLifecycle<T extends Lifecyclable<T>> implements Lifecyclable<T> { public abstract class AbstractLifecycle<T extends Lifecyclable<T>> implements Lifecyclable<T> {


private static final Logger LIFECYCLABLE_LOGGER = LoggerManager.getLogger(Lifecyclable.class);
private static final Runnable NOTHING = () -> {}; private static final Runnable NOTHING = () -> {};


private State state; private State state;
Expand Down Expand Up @@ -164,27 +167,81 @@ public void postStop() {


@Override @Override
public final T initialize() { public final T initialize() {
return Lifecyclable.super.initialize(); LIFECYCLABLE_LOGGER.debug("Initializing " + getClass().getSimpleName());
getState().checkNextState(State.INIITIALIZED);
preInitialize();
onInitialize();
setState(State.INIITIALIZED);
@SuppressWarnings("unchecked")
final T self = (T) this;
return self;
} }


@Override @Override
public final T load() { public final T load() {
return Lifecyclable.super.load(); if (getState() == State.CREATED) {
initialize();
}
LIFECYCLABLE_LOGGER.debug("Loading " + getClass().getSimpleName());
getState().checkNextState(State.LOADED);
preLoad();
onLoad();
setState(State.LOADED);
@SuppressWarnings("unchecked")
final T self = (T) this;
return self;
} }


@Override @Override
public final T resolve() { public final T resolve() {
return Lifecyclable.super.resolve(); if (getState() == State.CREATED) {
initialize();
}
if (getState() == State.INIITIALIZED) {
load();
}
LIFECYCLABLE_LOGGER.debug("Resolving " + getClass().getSimpleName());
getState().checkNextState(State.RESOLVED);
preResolve();
onResolve();
setState(State.RESOLVED);
@SuppressWarnings("unchecked")
final T self = (T) this;
return self;
} }


@Override @Override
public final T start() { public final T start() {
return Lifecyclable.super.start(); if (getState() == State.CREATED) {
initialize();
}
if (getState() == State.INIITIALIZED) {
load();
}
if (getState() == State.LOADED) {
resolve();
}
LIFECYCLABLE_LOGGER.debug("Starting " + getClass().getSimpleName());
getState().checkNextState(State.STARTED);
preStart();
onStart();
setState(State.STARTED);
@SuppressWarnings("unchecked")
final T self = (T) this;
return self;
} }


@Override @Override
public final T stop() { public final T stop() {
return Lifecyclable.super.stop(); LIFECYCLABLE_LOGGER.debug("Stopping " + getClass().getSimpleName());
getState().checkNextState(State.STOPPED);
preStop();
onStop();
postStop();
setState(State.STOPPED);
@SuppressWarnings("unchecked")
final T self = (T) this;
return self;
} }


@Override @Override
Expand Down
Expand Up @@ -14,7 +14,7 @@
* License for the specific language governing permissions and limitations under * License for the specific language governing permissions and limitations under
* the License. * the License.
*/ */
package com.speedment.runtime.util; package com.speedment.tool.util;


import com.speedment.runtime.config.Document; import com.speedment.runtime.config.Document;
import com.speedment.runtime.config.db.Column; import com.speedment.runtime.config.db.Column;
Expand Down
Expand Up @@ -14,7 +14,7 @@
* License for the specific language governing permissions and limitations under * License for the specific language governing permissions and limitations under
* the License. * the License.
*/ */
package com.speedment.runtime.util; package com.speedment.tool.util;


import com.speedment.runtime.config.db.Column; import com.speedment.runtime.config.db.Column;
import com.speedment.runtime.config.db.Dbms; import com.speedment.runtime.config.db.Dbms;
Expand Down

0 comments on commit ac793d3

Please sign in to comment.