com.marvelution.hudson.plugins.apiv2.dozer.converters.ResultDozerConverter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hudson-apiv2-plugin Show documentation
Show all versions of hudson-apiv2-plugin Show documentation
This plugin features a Wink REST API application.
/*
* Licensed to Marvelution under one or more contributor license
* agreements. See the NOTICE file distributed with this work
* for additional information regarding copyright ownership.
* Marvelution licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.marvelution.hudson.plugins.apiv2.dozer.converters;
import org.dozer.DozerConverter;
import com.marvelution.hudson.plugins.apiv2.resources.model.build.Result;
/**
* {@link DozerConverter} to convert a {@link hudson.model.Result} into a {@link Result} and back
*
* @author Mark Rekveld
*/
public class ResultDozerConverter extends DozerConverter {
/**
* Constructor
*/
public ResultDozerConverter() {
super(hudson.model.Result.class, Result.class);
}
/**
* {@inheritDoc}
*/
@Override
public Result convertTo(hudson.model.Result source, Result destination) {
if (source == null) {
return Result.NOTBUILD;
} else if (source.equals(hudson.model.Result.SUCCESS)) {
return Result.SUCCESSFUL;
} else if (source.equals(hudson.model.Result.FAILURE)) {
return Result.FAILED;
} else if (source.equals(hudson.model.Result.UNSTABLE)) {
return Result.UNSTABLE;
} else if (source.equals(hudson.model.Result.ABORTED)) {
return Result.ABORTED;
}
return Result.NOTBUILD;
}
/**
* {@inheritDoc}
*/
@Override
public hudson.model.Result convertFrom(Result source, hudson.model.Result destination) {
if (source == null) {
return hudson.model.Result.NOT_BUILT;
} else if (source.equals(Result.SUCCESSFUL)) {
return hudson.model.Result.SUCCESS;
} else if (source.equals(Result.FAILED)) {
return hudson.model.Result.FAILURE;
} else if (source.equals(Result.UNSTABLE)) {
return hudson.model.Result.UNSTABLE;
} else if (source.equals(Result.ABORTED)) {
return hudson.model.Result.ABORTED;
}
return hudson.model.Result.NOT_BUILT;
}
}