Carsten Ziegeler | 55c96d3 | 2012-06-13 12:03:35 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Licensed to the Apache Software Foundation (ASF) under one |
| 3 | * or more contributor license agreements. See the NOTICE file |
| 4 | * distributed with this work for additional information |
| 5 | * regarding copyright ownership. The ASF licenses this file |
| 6 | * to you under the Apache License, Version 2.0 (the |
| 7 | * "License"); you may not use this file except in compliance |
| 8 | * with the License. You may obtain a copy of the License at |
| 9 | * |
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | * |
| 12 | * Unless required by applicable law or agreed to in writing, |
| 13 | * software distributed under the License is distributed on an |
| 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | * KIND, either express or implied. See the License for the |
| 16 | * specific language governing permissions and limitations |
| 17 | * under the License. |
| 18 | */ |
| 19 | package org.apache.felix.scrplugin.description; |
| 20 | |
| 21 | public enum PropertyType { |
| 22 | |
| 23 | String, |
| 24 | Long, |
| 25 | Double, |
| 26 | Float, |
| 27 | Integer, |
| 28 | Byte, |
| 29 | Char, |
| 30 | Character, |
| 31 | Boolean, |
Carsten Ziegeler | 48cc4b3 | 2013-01-25 10:01:52 +0000 | [diff] [blame] | 32 | Short, |
Carsten Ziegeler | d04ccae | 2013-05-08 13:04:39 +0000 | [diff] [blame] | 33 | Password; |
Carsten Ziegeler | 55c96d3 | 2012-06-13 12:03:35 +0000 | [diff] [blame] | 34 | |
| 35 | public static PropertyType from(final Class<?> javaClass) { |
| 36 | if ( javaClass.getName().equals(Long.class.getName())) { |
| 37 | return PropertyType.Long; |
| 38 | } |
| 39 | if ( javaClass.getName().equals(Double.class.getName())) { |
| 40 | return PropertyType.Double; |
| 41 | } |
| 42 | if ( javaClass.getName().equals(Float.class.getName())) { |
| 43 | return PropertyType.Float; |
| 44 | } |
| 45 | if ( javaClass.getName().equals(Integer.class.getName())) { |
| 46 | return PropertyType.Integer; |
| 47 | } |
| 48 | if ( javaClass.getName().equals(Byte.class.getName())) { |
| 49 | return PropertyType.Byte; |
| 50 | } |
| 51 | if ( javaClass.getName().equals(Character.class.getName())) { |
| 52 | return PropertyType.Character; |
| 53 | } |
| 54 | if ( javaClass.getName().equals(Boolean.class.getName())) { |
| 55 | return PropertyType.Boolean; |
| 56 | } |
| 57 | if ( javaClass.getName().equals(Short.class.getName())) { |
| 58 | return PropertyType.Short; |
| 59 | } |
| 60 | // default |
| 61 | return PropertyType.String; |
| 62 | } |
| 63 | } |