Java tutorial
/* * Copyright (c) 2014 Kaiserpfalz EDV-Service, Roland Lichti * * Licensed 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 de.kaiserpfalzEdv.iam.role; import de.kaiserpfalzEdv.commons.IdentifiableReadable; import de.kaiserpfalzEdv.commons.NameableReadable; import org.apache.commons.lang3.builder.Builder; /** * @author klenkes * @since 2014Q */ public class PermissionQueryBuilder implements Builder<PermissionQuery> { private PermissionQuery query = new PermissionQuery(); @Override public PermissionQuery build() { if (query.isValid()) return query; throw new IllegalStateException("The permission object can not be built!"); } public PermissionQueryBuilder withName(NameableReadable name) { query.setName(name.getName()); query.setCode(name.getShortName()); query.setCanonicalName(name.getCanonicalName()); query.setDisplayName(name.getDisplayName()); return this; } public PermissionQueryBuilder withId(IdentifiableReadable id) { query.setId(id); return this; } }