Spec-Zone .ru
спецификации, руководства, описания, API
|
001/* 002 * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. 003 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 004 * 005 * This code is free software; you can redistribute it and/or modify it 006 * under the terms of the GNU General Public License version 2 only, as 007 * published by the Free Software Foundation. Oracle designates this 008 * particular file as subject to the "Classpath" exception as provided 009 * by Oracle in the LICENSE file that accompanied this code. 010 * 011 * This code is distributed in the hope that it will be useful, but WITHOUT 012 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 013 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 014 * version 2 for more details (a copy is included in the LICENSE file that 015 * accompanied this code). 016 * 017 * You should have received a copy of the GNU General Public License version 018 * 2 along with this work; if not, write to the Free Software Foundation, 019 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 020 * 021 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 022 * or visit www.oracle.com if you need additional information or have any 023 * questions. 024 */ 025 026package javafx.beans.property; 027 028import javafx.collections.ObservableMap; 029import javafx.collections.ObservableSet; 030 031/** 032 * This class provides a full implementation of a {@link Property} wrapping an 033 * {@code ObservableMap}. 034 * 035 * @see MapPropertyBase 036 * 037 * @param <K> the type of the key elements of the {@code Map} 038 * @param <V> the type of the value elements of the {@code Map} 039 */ 040public class SimpleMapProperty<K, V> extends MapPropertyBase<K, V> { 041 042 private static final Object DEFAULT_BEAN = null; 043 private static final String DEFAULT_NAME = ""; 044 045 private final Object bean; 046 private final String name; 047 048 /** 049 * {@inheritDoc} 050 */ 051 @Override 052 public Object getBean() { 053 return bean; 054 } 055 056 /** 057 * {@inheritDoc} 058 */ 059 @Override 060 public String getName() { 061 return name; 062 } 063 064 /** 065 * The constructor of {@code SimpleMapProperty} 066 */ 067 public SimpleMapProperty() { 068 this(DEFAULT_BEAN, DEFAULT_NAME); 069 } 070 071 /** 072 * The constructor of {@code SimpleMapProperty} 073 * 074 * @param initialValue 075 * the initial value of the wrapped value 076 */ 077 public SimpleMapProperty(ObservableMap<K, V> initialValue) { 078 this(DEFAULT_BEAN, DEFAULT_NAME, initialValue); 079 } 080 081 /** 082 * The constructor of {@code SimpleMapProperty} 083 * 084 * @param bean 085 * the bean of this {@code MapProperty} 086 * @param name 087 * the name of this {@code MapProperty} 088 */ 089 public SimpleMapProperty(Object bean, String name) { 090 this.bean = bean; 091 this.name = (name == null) ? DEFAULT_NAME : name; 092 } 093 094 /** 095 * The constructor of {@code SimpleMapProperty} 096 * 097 * @param bean 098 * the bean of this {@code MapProperty} 099 * @param name 100 * the name of this {@code MapProperty} 101 * @param initialValue 102 * the initial value of the wrapped value 103 */ 104 public SimpleMapProperty(Object bean, String name, ObservableMap<K, V> initialValue) { 105 super(initialValue); 106 this.bean = bean; 107 this.name = (name == null) ? DEFAULT_NAME : name; 108 } 109 110}