dubbo MultiMessage 源码
dubbo MultiMessage 代码
文件路径:/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/exchange/support/MultiMessage.java
/*
* 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.apache.dubbo.remoting.exchange.support;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
/**
* @see org.apache.dubbo.remoting.transport.MultiMessageHandler
*/
public final class MultiMessage implements Iterable {
private final List messages = new ArrayList();
private MultiMessage() {
}
public static MultiMessage createFromCollection(Collection collection) {
MultiMessage result = new MultiMessage();
result.addMessages(collection);
return result;
}
public static MultiMessage createFromArray(Object... args) {
return createFromCollection(Arrays.asList(args));
}
public static MultiMessage create() {
return new MultiMessage();
}
public void addMessage(Object msg) {
messages.add(msg);
}
public void addMessages(Collection collection) {
messages.addAll(collection);
}
public Collection getMessages() {
return Collections.unmodifiableCollection(messages);
}
public int size() {
return messages.size();
}
public Object get(int index) {
return messages.get(index);
}
public boolean isEmpty() {
return messages.isEmpty();
}
public Collection removeMessages() {
Collection result = Collections.unmodifiableCollection(messages);
messages.clear();
return result;
}
@Override
public Iterator iterator() {
return messages.iterator();
}
}
相关信息
相关文章
dubbo ExchangeHandlerAdapter 源码
dubbo ExchangeHandlerDispatcher 源码
0
赞
热门推荐
-
2、 - 优质文章
-
3、 gate.io
-
7、 golang
-
9、 openharmony
-
10、 Vue中input框自动聚焦