//Copyright 2015 Erik De Rijcke
//
//Licensed under the Apache License,Version2.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 org.westmalle.wayland.protocol;

import com.google.auto.factory.AutoFactory;
import com.google.common.collect.Sets;
import org.freedesktop.wayland.server.Client;
import org.freedesktop.wayland.server.WlKeyboardRequestsV3;
import org.freedesktop.wayland.server.WlKeyboardResource;
import org.westmalle.wayland.core.Keyboard;

import javax.annotation.Nonnegative;
import javax.annotation.Nonnull;
import java.util.Set;
import java.util.WeakHashMap;

@AutoFactory(className = "WlKeyboardFactory")
public class WlKeyboard implements WlKeyboardRequestsV3, ProtocolObject<WlKeyboardResource> {

    private final Set<WlKeyboardResource> resources = Sets.newSetFromMap(new WeakHashMap<>());
    private final Keyboard keyboard;

    WlKeyboard(final Keyboard keyboard) {
        this.keyboard = keyboard;
    }

    @Override
    public void release(final WlKeyboardResource resource) {
        resource.destroy();
    }

    @Nonnull
    @Override
    public Set<WlKeyboardResource> getResources() {
        return this.resources;
    }

    @Nonnull
    @Override
    public WlKeyboardResource create(@Nonnull final Client client,
                                     @Nonnegative final int version,
                                     final int id) {
        return new WlKeyboardResource(client,
                                      version,
                                      id,
                                      this);
    }

    public Keyboard getKeyboard() {
        return this.keyboard;
    }
}

@@ -686,16 +686,17 @@
 t.Sets;%0A
+%0A
 import o
@@ -790,17 +790,17 @@
 equestsV
-3
+4
 ;%0Aimport
@@ -911,33 +911,49 @@
 java
-x.annotation.Nonnegative;
+.util.Set;%0Aimport java.util.WeakHashMap;%0A
 %0Aimp
@@ -977,19 +977,23 @@
 ion.Nonn
-ull
+egative
 ;%0Aimport
@@ -1001,47 +1001,28 @@
 java
-.util.Set;%0Aimport java.util.WeakHashMap
+x.annotation.Nonnull
 ;%0A%0A@
@@ -1124,9 +1124,9 @@
 stsV
-3
+4
 , Pr

use keyboard v4