Java Type Coerce coerceIntoEntityId(Long comboId)

Here you can find the source of coerceIntoEntityId(Long comboId)

Description

Inverse operation of #coerceIntoComboId(Long)

License

Open Source License

Parameter

Parameter Description
comboId a parameter

Return

passes through null values, translates into entity id otherwise.

Declaration

public static Long coerceIntoEntityId(Long comboId) 

Method Source Code

//package com.java2s;
/**/*  w ww  .  j av a  2  s  .  c om*/
 *     This file is part of the Squashtest platform.
 *     Copyright (C) 2010 - 2016 Henix, henix.fr
 *
 *     See the NOTICE file distributed with this work for additional
 *     information regarding copyright ownership.
 *
 *     This is free software: you can redistribute it and/or modify
 *     it under the terms of the GNU Lesser General Public License as published by
 *     the Free Software Foundation, either version 3 of the License, or
 *     (at your option) any later version.
 *
 *     this software is distributed in the hope that it will be useful,
 *     but WITHOUT ANY WARRANTY; without even the implied warranty of
 *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *     GNU Lesser General Public License for more details.
 *
 *     You should have received a copy of the GNU Lesser General Public License
 *     along with this software.  If not, see <http://www.gnu.org/licenses/>.
 */

public class Main {
    private static final int ID_OFFSET = 10;

    /**
     * Inverse operation of {@link #coerceIntoComboId(Long)}
     * 
     * @param comboId
     * @return passes through <code>null</code> values, translates into entity id otherwise.
     * @see #coerceIntoComboId(Long)
     */
    public static Long coerceIntoEntityId(Long comboId) {
        if (comboId == null || comboId == 0) {
            return null;
        }
        return comboId - ID_OFFSET;
    }
}

Related

  1. coerce(Object value, Class clazz)
  2. coerce(Object value, Class clazz)
  3. coerceBool(Object obj)
  4. coerceBool(Object val)
  5. coerceIntoComboId(Long entityId)
  6. coerceTagValueInt(String tag, Object val)
  7. coerceToDouble(Object o)
  8. coerceToEntrySize(String s)
  9. coerceToString(Object object)