java.util.TreeMap $ Entry.entrySet()适用于参数类型:()values:[] [英] java.util.TreeMap$Entry.entrySet() is applicable for argument types: () values: []
问题描述
我有 ChatDayWrappers
,它包含双方数据库中所有消息在一天之内。
我可以使用来自对象 chatWrapper.getChatDayWrappers()[0];
的47个项目来获取chatRowWrappers吗?
$ b
$ b
代码
chatWrapper.getChatDayWrappers()[0];
getLogger()。info(chatWrapper:+ object.getClass()。getName());
输出
java.util.TreeMap $ Entry
另一个尝试: 我已经厌倦了以下内容: 但我得到了这个错误: 没有方法的签名:java.util.TreeMap $ Entry.entrySet()适用于参数类型:()values:[] CockpitChatWrapper 截图 返回一个Object数组,您无法直接访问地图内的ChatDisplayDayWrapper对象。相反,您可以将您的getter修改为: I have How can I get the the chatRowWrappers with the 47 items from the object Code output Another try: I have tired the following: but I got this error: No signature of method: java.util.TreeMap$Entry.entrySet() is applicable for argument types: () values: []
Possible solutions: every(): groovy.lang.MissingMethodException: No signature of method: java.util.TreeMap$Entry.entrySet() is applicable for argument types: () values: [] CockpitChatWrapper screenshot The issue here is: returns an Object array that you cannot directly access the ChatDisplayDayWrapper object inside the map. Instead, you could modify your getter to:
这篇关于java.util.TreeMap $ Entry.entrySet()适用于参数类型:()values:[]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
Object object [] = chatWrapper.getChatDayWrappers()[0] .entrySet()。toArray();
getLogger()。info(chatWrapper:+ object.getClass()。getName());
可能的解决方案:every():groovy.lang。 MissingMethodException:没有方法的签名:java.util.TreeMap $ Entry.entrySet()适用于参数类型:()values:[]
公共类CockpitChatWrapper
实现Serializable {
private static final long serialVersionUID = 1L;
public static final String STYLE_CHAT_UNKNOWN =tpChatUnknown;
public static final String STYLE_CHAT_FROM =tpChatFrom;
public static final String STYLE_CHAT_TO =tpChatTo;
/ **用于格式化报告中的日期。 * /
private static final ThreadLocal< SimpleDateFormat> DATE_FORMAT = new ThreadLocal< SimpleDateFormat>(){
@Override
保护SimpleDateFormat initialValue(){
返回新的SimpleDateFormat(yyyy-MM-dd);
}
};
private final Map< String,ChatDisplayDayWrapper> chatDayWrappers;
private final Long currentUserId;
private final Long currentFlexiObjectId;
/ **
*构造函数。
*
* @param currentUserId用户标识。
* @param currentFlexiObjectId flexiObejct Id。
* /
public CockpitChatWrapper(final Long currentUserId,final Long currentFlexiObjectId){
this.chatDayWrappers = new TreeMap< String,ChatDisplayDayWrapper>(new Comparator< String>(){
public int compare(final String o1,final String o2){
return(o1.compareTo(o2)* -1);
}
});
this.currentUserId = currentUserId;
this.currentFlexiObjectId = currentFlexiObjectId;
}
/ **
*
*添加聊天记录。
*
* @param聊天聊天记录。
* /
public void addChatEntry(final Chat chat){
String key = CockpitChatWrapper.DATE_FORMAT.get()。format(chat.getLastWrite());
ChatDisplayDayWrapper entry = null;
if(this.chatDayWrappers.get(key)!= null){
entry = this.chatDayWrappers.get(key);
} else {
entry = new ChatDisplayDayWrapper(chat.getLastWrite());
this.chatDayWrappers.put(key,entry);
}
entry.addChat(chat,this.currentUserId,this.currentFlexiObjectId);
}
/ **
*返回chatDayWrappers。
*
* @return返回chatDayWrappers。
* /
public Object [] getChatDayWrappers(){
return this.chatDayWrappers.entrySet()。toArray();
}
public boolean getHasChatDayWrappers(){
return this.chatDayWrappers!= null&& this.chatDayWrappers.size()> 0;
}
/ **
*
*将聊天记录保留一天。
*
* /
public static class ChatDisplayDayWrapper
实现Serializable {
private static final long serialVersionUID = 1L;
私人决赛日期日;
private final List< ChatDisplayRowWrapper> chatRowWrappers;
/ **
*
*构造函数。
*
* @param day设置的日期。
* /
public ChatDisplayDayWrapper(final date day){
this.day = day;
this.chatRowWrappers = new ArrayList< ChatDisplayRowWrapper>();
$ b private void addChat(最终聊天聊天,最终Long currentUserId,最终Long currentFlexiObjectId){
String styleClass = CockpitChatWrapper.STYLE_CHAT_UNKNOWN; ()currentUserId!= null&& chat.getFromUser()!= null
&&&& currentUserId.longValue()== chat.getFromUser()。getId() .longValue()){
styleClass = CockpitChatWrapper.STYLE_CHAT_FROM;
} else if(currentFlexiObjectId!= null&&&& chat.getFromFlexiObject()!= null
&&&&& amp; currentFlexiObjectId.longValue()== chat.getFromFlexiObject()。getId()。longValue ()){
styleClass = CockpitChatWrapper.STYLE_CHAT_TO;
}
this.chatRowWrappers.add(new ChatDisplayRowWrapper(chat,styleClass));
}
/ **
*返回当天。
*
* @return返回一天。
* /
public Date getDay(){
return this.day;
}
/ **
*返回chatRowWrappers。
*
* @return返回chatRowWrappers。
* /
public List< ChatDisplayRowWrapper> getChatRowWrappers(){
返回this.chatRowWrappers;
}
}
}
$ p $ public Object [] getChatDayWrappers(){
返回this.chatDayWrappers.entrySet()。toArray();
}
public List< ChatDisplayRowWrapper> getChatDayWrappers(){
return m.entrySet()。stream()。map(entry - > entry.getValue())。collect(Collectors.toList()); }
}
ChatDayWrappers
which contains all messages in the database between the two parties for one day.chatWrapper.getChatDayWrappers()[0];
? Object object = chatWrapper.getChatDayWrappers()[0];
getLogger().info("chatWrapper: " + object.getClass().getName());
java.util.TreeMap$Entry
Object object[] = chatWrapper.getChatDayWrappers()[0].entrySet().toArray();
getLogger().info("chatWrapper: " + object.getClass().getName());
public class CockpitChatWrapper
implements Serializable {
private static final long serialVersionUID = 1L;
public static final String STYLE_CHAT_UNKNOWN = "tpChatUnknown";
public static final String STYLE_CHAT_FROM = "tpChatFrom";
public static final String STYLE_CHAT_TO = "tpChatTo";
/** Used to format the dates in the report. */
private static final ThreadLocal<SimpleDateFormat> DATE_FORMAT = new ThreadLocal<SimpleDateFormat>() {
@Override
protected SimpleDateFormat initialValue() {
return new SimpleDateFormat("yyyy-MM-dd");
}
};
private final Map<String, ChatDisplayDayWrapper> chatDayWrappers;
private final Long currentUserId;
private final Long currentFlexiObjectId;
/**
* Constructor.
*
* @param currentUserId The user Id.
* @param currentFlexiObjectId The flexiObejct Id.
*/
public CockpitChatWrapper(final Long currentUserId, final Long currentFlexiObjectId) {
this.chatDayWrappers = new TreeMap<String, ChatDisplayDayWrapper>(new Comparator<String>() {
public int compare(final String o1, final String o2) {
return (o1.compareTo(o2) * -1);
}
});
this.currentUserId = currentUserId;
this.currentFlexiObjectId = currentFlexiObjectId;
}
/**
*
* Add a chat entry.
*
* @param chat The chat entry.
*/
public void addChatEntry(final Chat chat) {
String key = CockpitChatWrapper.DATE_FORMAT.get().format(chat.getLastWrite());
ChatDisplayDayWrapper entry = null;
if (this.chatDayWrappers.get(key) != null) {
entry = this.chatDayWrappers.get(key);
} else {
entry = new ChatDisplayDayWrapper(chat.getLastWrite());
this.chatDayWrappers.put(key, entry);
}
entry.addChat(chat, this.currentUserId, this.currentFlexiObjectId);
}
/**
* Returns the chatDayWrappers.
*
* @return Returns the chatDayWrappers.
*/
public Object[] getChatDayWrappers() {
return this.chatDayWrappers.entrySet().toArray();
}
public boolean getHasChatDayWrappers() {
return this.chatDayWrappers != null && this.chatDayWrappers.size() > 0;
}
/**
*
* Hold the chat entries for an day.
*
*/
public static class ChatDisplayDayWrapper
implements Serializable {
private static final long serialVersionUID = 1L;
private final Date day;
private final List<ChatDisplayRowWrapper> chatRowWrappers;
/**
*
* Constructor.
*
* @param day The day to set.
*/
public ChatDisplayDayWrapper(final Date day) {
this.day = day;
this.chatRowWrappers = new ArrayList<ChatDisplayRowWrapper>();
}
private void addChat(final Chat chat, final Long currentUserId, final Long currentFlexiObjectId) {
String styleClass = CockpitChatWrapper.STYLE_CHAT_UNKNOWN;
if (currentUserId != null && chat.getFromUser() != null
&& currentUserId.longValue() == chat.getFromUser().getId().longValue()) {
styleClass = CockpitChatWrapper.STYLE_CHAT_FROM;
} else if (currentFlexiObjectId != null && chat.getFromFlexiObject() != null
&& currentFlexiObjectId.longValue() == chat.getFromFlexiObject().getId().longValue()) {
styleClass = CockpitChatWrapper.STYLE_CHAT_TO;
}
this.chatRowWrappers.add(new ChatDisplayRowWrapper(chat, styleClass));
}
/**
* Returns the day.
*
* @return Returns the day.
*/
public Date getDay() {
return this.day;
}
/**
* Returns the chatRowWrappers.
*
* @return Returns the chatRowWrappers.
*/
public List<ChatDisplayRowWrapper> getChatRowWrappers() {
return this.chatRowWrappers;
}
}
}
public Object[] getChatDayWrappers() {
return this.chatDayWrappers.entrySet().toArray();
}
public List<ChatDisplayRowWrapper> getChatDayWrappers() {
return m.entrySet().stream().map(entry -> entry.getValue()).collect(Collectors.toList()); }
}