com.marvelution.hudson.plugins.apiv2.dozer.converters.UserEmailAddressDozerConvertor 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 hudson.model.User;
import hudson.tasks.Mailer;
import hudson.tasks.Mailer.UserProperty;
import org.dozer.DozerConverter;
/**
* {@link hudson.model.User} to email address {@link DozerConverter}
*
* @author Mark Rekveld
* @since 4.2.0
*/
public class UserEmailAddressDozerConvertor extends DozerConverter {
/**
* Default Constructor
*/
public UserEmailAddressDozerConvertor() {
super(User.class, String.class);
}
/**
* {@inheritDoc}
*/
@Override
public String convertTo(User source, String destination) {
UserProperty property = source.getProperty(Mailer.UserProperty.class);
if (property != null && property.getAddress() != null) {
destination = property.getAddress();
} else {
destination = "";
}
return destination;
}
/**
* {@inheritDoc}
*/
@Override
public User convertFrom(String source, User destination) {
throw new UnsupportedOperationException("Cannot convert from a String to a User");
}
}