Java tutorial
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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 org.waveprotocol.box.profile.jso; import static org.waveprotocol.wave.communication.gwt.JsonHelper.*; import com.google.gwt.core.client.*; /** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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. */ /** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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. */ import org.waveprotocol.box.profile.ProfileRequest; import org.waveprotocol.box.profile.ProfileRequestUtil; import org.waveprotocol.wave.communication.Blob; import org.waveprotocol.wave.communication.ProtoEnums; import org.waveprotocol.wave.communication.gwt.*; import org.waveprotocol.wave.communication.json.*; import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Set; /** * Client implementation of ProfileRequest backed by a GWT JavaScriptObject. * * Generated from org/waveprotocol/box/profile/profiles.proto. Do not edit. */ /** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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. */ /** We have to use fully-qualified name of the GsonSerializable class here in order to make it * visible in case of nested classes. */ public final class ProfileRequestJsoImpl extends org.waveprotocol.wave.communication.gwt.JsonMessage implements ProfileRequest { private static final String keyAddresses = "1"; protected ProfileRequestJsoImpl() { } public static ProfileRequestJsoImpl create() { ProfileRequestJsoImpl instance = (ProfileRequestJsoImpl) JsonMessage.createJsonMessage(); // Force all lists to start with an empty list rather than no property for // the list. This is so that the native JS equality works, since (obviously) // {} != {"foo": []} while in the context of messages they should be. instance.clearAddresses(); return instance; } @Override public void copyFrom(ProfileRequest message) { super.copyFrom((ProfileRequestJsoImpl) message); } /** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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. */ @Override public List<String> getAddresses() { initArray(this, keyAddresses); List<String> list = new ArrayList<String>(); for (int i = 0; i < getAddressesSize(); i++) { list.add(getAddresses(i)); } return list; } @Override public void addAllAddresses(List<String> values) { for (String value : values) { addAddresses(value); } } @Override @SuppressWarnings("unchecked") public String getAddresses(int n) { initArray(this, keyAddresses); JsArrayString array = getPropertyAsObject(this, keyAddresses).cast(); if (n < 0) throw new IllegalArgumentException("index " + n + " < 0"); if (array.length() <= n) throw new IllegalArgumentException("index " + n + ">= array length " + array.length()); return array.get(n); } @Override public void setAddresses(int n, String value) { if (n < 0) throw new IllegalArgumentException("index " + n + " < 0"); initArray(this, keyAddresses); ((JsArrayString) getPropertyAsObject(this, keyAddresses)).set(n, value); } @Override public int getAddressesSize() { return hasProperty(this, keyAddresses) ? ((JsArray<?>) getPropertyAsObject(this, keyAddresses)).length() : 0; } @Override public void addAddresses(String value) { initArray(this, keyAddresses); ((JsArrayString) getPropertyAsObject(this, keyAddresses)).push(value); } @Override public void clearAddresses() { clearArray(this, keyAddresses); } @Override public boolean isEqualTo(Object o) { if (o instanceof ProfileRequestJsoImpl) { return nativeIsEqualTo(o); } else if (o instanceof ProfileRequest) { return ProfileRequestUtil.isEqual(this, (ProfileRequest) o); } else { return false; } } }